diff options
Diffstat (limited to 'apps/plugins/mpegplayer/stream_mgr.h')
-rw-r--r-- | apps/plugins/mpegplayer/stream_mgr.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h new file mode 100644 index 0000000000..63452ecbc0 --- /dev/null +++ b/apps/plugins/mpegplayer/stream_mgr.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * AV stream manager decalarations | ||
11 | * | ||
12 | * Copyright (c) 2007 Michael Sevakis | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef STREAM_MGR_H | ||
22 | #define STREAM_MGR_H | ||
23 | |||
24 | /* Basic media control interface - this handles state changes and stream | ||
25 | * coordination with assistance from the parser */ | ||
26 | struct stream_mgr | ||
27 | { | ||
28 | struct thread_entry *thread; /* Playback control thread */ | ||
29 | struct event_queue *q; /* event queue for control thread */ | ||
30 | const char *filename; /* Current filename */ | ||
31 | uint32_t resume_time; /* The stream tick where playback was | ||
32 | stopped (or started) */ | ||
33 | bool seeked; /* A seek happened and things must be | ||
34 | resynced */ | ||
35 | int status; /* Current playback status */ | ||
36 | struct list_item strl; /* List of available streams */ | ||
37 | struct list_item actl; /* List of active streams */ | ||
38 | struct mutex str_mtx; /* Main stream manager mutex */ | ||
39 | struct mutex actl_mtx; /* Lock for current-streams list */ | ||
40 | #ifndef HAVE_LCD_COLOR | ||
41 | void *graymem; | ||
42 | size_t graysize; | ||
43 | #endif | ||
44 | union /* A place for reusable non-cacheable parameters */ | ||
45 | { | ||
46 | struct vo_rect rc; | ||
47 | struct stream_seek_data skd; | ||
48 | } parms; | ||
49 | }; | ||
50 | |||
51 | extern struct stream_mgr stream_mgr NOCACHEBSS_ATTR; | ||
52 | |||
53 | struct stream_window | ||
54 | { | ||
55 | off_t left, right; | ||
56 | }; | ||
57 | |||
58 | /** Interface for use by streams and other internal objects **/ | ||
59 | bool stream_get_window(struct stream_window *sw); | ||
60 | void stream_clear_notify(struct stream *str, int for_msg); | ||
61 | int str_next_data_not_ready(struct stream *str); | ||
62 | /* Called by a stream to say it got its buffering notification */ | ||
63 | void str_data_notify_received(struct stream *str); | ||
64 | void stream_add_stream(struct stream *str); | ||
65 | void stream_remove_streams(void); | ||
66 | |||
67 | enum stream_events | ||
68 | { | ||
69 | __STREAM_EV_FIRST = STREAM_MESSAGE_LAST-1, | ||
70 | STREAM_EV_COMPLETE, | ||
71 | }; | ||
72 | |||
73 | void stream_generate_event(struct stream *str, long id, intptr_t data); | ||
74 | |||
75 | /** Main control functions **/ | ||
76 | |||
77 | /* Initialize the playback engine */ | ||
78 | int stream_init(void); | ||
79 | |||
80 | /* Close the playback engine */ | ||
81 | void stream_exit(void); | ||
82 | |||
83 | /* Open a new file */ | ||
84 | int stream_open(const char *filename); | ||
85 | |||
86 | /* Close the current file */ | ||
87 | int stream_close(void); | ||
88 | |||
89 | /* Plays from the current seekpoint if stopped */ | ||
90 | int stream_play(void); | ||
91 | |||
92 | /* Pauses playback if playing */ | ||
93 | int stream_pause(void); | ||
94 | |||
95 | /* Resumes playback if paused */ | ||
96 | int stream_resume(void); | ||
97 | |||
98 | /* Stops all streaming activity if playing or paused */ | ||
99 | int stream_stop(void); | ||
100 | |||
101 | /* Point stream at a particular time. | ||
102 | * whence = one of SEEK_SET, SEEK_CUR, SEEK_END */ | ||
103 | int stream_seek(uint32_t time, int whence); | ||
104 | |||
105 | /* Show/Hide the video image at the current seekpoint */ | ||
106 | bool stream_show_vo(bool show); | ||
107 | |||
108 | #ifndef HAVE_LCD_COLOR | ||
109 | /* Set the gray overlay rectangle */ | ||
110 | bool stream_set_gray_rect(const struct vo_rect *rc); | ||
111 | void stream_gray_show(bool show); | ||
112 | #endif | ||
113 | |||
114 | /* Display thumbnail of the current seekpoint */ | ||
115 | bool stream_display_thumb(const struct vo_rect *rc); | ||
116 | |||
117 | /* Return video dimensions */ | ||
118 | bool stream_vo_get_size(struct vo_ext *sz); | ||
119 | |||
120 | /* Returns the resume time in timestamp ticks */ | ||
121 | uint32_t stream_get_resume_time(void); | ||
122 | |||
123 | /* Return the absolute stream time in clock ticks - adjusted by | ||
124 | * master clock stream via audio timestamps */ | ||
125 | static inline uint32_t stream_get_time(void) | ||
126 | { return pcm_output_get_clock(); } | ||
127 | |||
128 | /* Return the absolute clock time in clock ticks - unadjusted */ | ||
129 | static inline uint32_t stream_get_ticks(uint32_t *start) | ||
130 | { return pcm_output_get_ticks(start); } | ||
131 | |||
132 | /* Returns the current playback status */ | ||
133 | static inline int stream_status(void) | ||
134 | { return stream_mgr.status; } | ||
135 | |||
136 | /* Returns the playback length of the stream */ | ||
137 | static inline uint32_t stream_get_duration(void) | ||
138 | { return str_parser.duration; } | ||
139 | |||
140 | static inline bool stream_can_seek(void) | ||
141 | { return parser_can_seek(); } | ||
142 | |||
143 | /* Keep the disk spinning (for seeking and browsing) */ | ||
144 | static inline void stream_keep_disk_active(void) | ||
145 | { | ||
146 | #ifndef HAVE_FLASH_STORAGE | ||
147 | rb->ata_spin(); | ||
148 | #endif | ||
149 | } | ||
150 | |||
151 | #endif /* STREAM_MGR_H */ | ||