forked from len0rd/rockbox
mpegplayer: Make playback engine fully seekable and frame-accurate and split into logical parts. Be sure to have all current features work. Actual UI for seeking will be added soon. Recommended GOP size is about 15-30 frames depending on target or seeking can be slow with really long GOPs (nature of MPEG video). More refined encoding recommendations for a particular player should be posted soon.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15977 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1d0f6b90ff
commit
a222f27c4a
34 changed files with 7850 additions and 2764 deletions
151
apps/plugins/mpegplayer/stream_mgr.h
Normal file
151
apps/plugins/mpegplayer/stream_mgr.h
Normal file
|
@ -0,0 +1,151 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* AV stream manager decalarations
|
||||
*
|
||||
* Copyright (c) 2007 Michael Sevakis
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef STREAM_MGR_H
|
||||
#define STREAM_MGR_H
|
||||
|
||||
/* Basic media control interface - this handles state changes and stream
|
||||
* coordination with assistance from the parser */
|
||||
struct stream_mgr
|
||||
{
|
||||
struct thread_entry *thread; /* Playback control thread */
|
||||
struct event_queue *q; /* event queue for control thread */
|
||||
const char *filename; /* Current filename */
|
||||
uint32_t resume_time; /* The stream tick where playback was
|
||||
stopped (or started) */
|
||||
bool seeked; /* A seek happened and things must be
|
||||
resynced */
|
||||
int status; /* Current playback status */
|
||||
struct list_item strl; /* List of available streams */
|
||||
struct list_item actl; /* List of active streams */
|
||||
struct mutex str_mtx; /* Main stream manager mutex */
|
||||
struct mutex actl_mtx; /* Lock for current-streams list */
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
void *graymem;
|
||||
size_t graysize;
|
||||
#endif
|
||||
union /* A place for reusable non-cacheable parameters */
|
||||
{
|
||||
struct vo_rect rc;
|
||||
struct stream_seek_data skd;
|
||||
} parms;
|
||||
};
|
||||
|
||||
extern struct stream_mgr stream_mgr NOCACHEBSS_ATTR;
|
||||
|
||||
struct stream_window
|
||||
{
|
||||
off_t left, right;
|
||||
};
|
||||
|
||||
/** Interface for use by streams and other internal objects **/
|
||||
bool stream_get_window(struct stream_window *sw);
|
||||
void stream_clear_notify(struct stream *str, int for_msg);
|
||||
int str_next_data_not_ready(struct stream *str);
|
||||
/* Called by a stream to say it got its buffering notification */
|
||||
void str_data_notify_received(struct stream *str);
|
||||
void stream_add_stream(struct stream *str);
|
||||
void stream_remove_streams(void);
|
||||
|
||||
enum stream_events
|
||||
{
|
||||
__STREAM_EV_FIRST = STREAM_MESSAGE_LAST-1,
|
||||
STREAM_EV_COMPLETE,
|
||||
};
|
||||
|
||||
void stream_generate_event(struct stream *str, long id, intptr_t data);
|
||||
|
||||
/** Main control functions **/
|
||||
|
||||
/* Initialize the playback engine */
|
||||
int stream_init(void);
|
||||
|
||||
/* Close the playback engine */
|
||||
void stream_exit(void);
|
||||
|
||||
/* Open a new file */
|
||||
int stream_open(const char *filename);
|
||||
|
||||
/* Close the current file */
|
||||
int stream_close(void);
|
||||
|
||||
/* Plays from the current seekpoint if stopped */
|
||||
int stream_play(void);
|
||||
|
||||
/* Pauses playback if playing */
|
||||
int stream_pause(void);
|
||||
|
||||
/* Resumes playback if paused */
|
||||
int stream_resume(void);
|
||||
|
||||
/* Stops all streaming activity if playing or paused */
|
||||
int stream_stop(void);
|
||||
|
||||
/* Point stream at a particular time.
|
||||
* whence = one of SEEK_SET, SEEK_CUR, SEEK_END */
|
||||
int stream_seek(uint32_t time, int whence);
|
||||
|
||||
/* Show/Hide the video image at the current seekpoint */
|
||||
bool stream_show_vo(bool show);
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
/* Set the gray overlay rectangle */
|
||||
bool stream_set_gray_rect(const struct vo_rect *rc);
|
||||
void stream_gray_show(bool show);
|
||||
#endif
|
||||
|
||||
/* Display thumbnail of the current seekpoint */
|
||||
bool stream_display_thumb(const struct vo_rect *rc);
|
||||
|
||||
/* Return video dimensions */
|
||||
bool stream_vo_get_size(struct vo_ext *sz);
|
||||
|
||||
/* Returns the resume time in timestamp ticks */
|
||||
uint32_t stream_get_resume_time(void);
|
||||
|
||||
/* Return the absolute stream time in clock ticks - adjusted by
|
||||
* master clock stream via audio timestamps */
|
||||
static inline uint32_t stream_get_time(void)
|
||||
{ return pcm_output_get_clock(); }
|
||||
|
||||
/* Return the absolute clock time in clock ticks - unadjusted */
|
||||
static inline uint32_t stream_get_ticks(uint32_t *start)
|
||||
{ return pcm_output_get_ticks(start); }
|
||||
|
||||
/* Returns the current playback status */
|
||||
static inline int stream_status(void)
|
||||
{ return stream_mgr.status; }
|
||||
|
||||
/* Returns the playback length of the stream */
|
||||
static inline uint32_t stream_get_duration(void)
|
||||
{ return str_parser.duration; }
|
||||
|
||||
static inline bool stream_can_seek(void)
|
||||
{ return parser_can_seek(); }
|
||||
|
||||
/* Keep the disk spinning (for seeking and browsing) */
|
||||
static inline void stream_keep_disk_active(void)
|
||||
{
|
||||
#ifndef HAVE_FLASH_STORAGE
|
||||
rb->ata_spin();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* STREAM_MGR_H */
|
Loading…
Add table
Add a link
Reference in a new issue