1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * AV stream manager decalarations
12 * Copyright (c) 2007 Michael Sevakis
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 /* Basic media control interface - this handles state changes and stream
25 * coordination with assistance from the parser */
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
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 union /* A place for reusable non-cacheable parameters */
43 struct stream_seek_data skd
;
47 extern struct stream_mgr stream_mgr NOCACHEBSS_ATTR
;
54 /** Interface for use by streams and other internal objects **/
55 bool stream_get_window(struct stream_window
*sw
);
56 void stream_clear_notify(struct stream
*str
, int for_msg
);
57 int str_next_data_not_ready(struct stream
*str
);
58 /* Called by a stream to say it got its buffering notification */
59 void str_data_notify_received(struct stream
*str
);
60 void stream_add_stream(struct stream
*str
);
61 void stream_remove_streams(void);
65 __STREAM_EV_FIRST
= STREAM_MESSAGE_LAST
-1,
69 void stream_generate_event(struct stream
*str
, long id
, intptr_t data
);
71 /** Main control functions **/
73 /* Initialize the playback engine */
74 int stream_init(void);
76 /* Close the playback engine */
77 void stream_exit(void);
80 int stream_open(const char *filename
);
82 /* Close the current file */
83 int stream_close(void);
85 /* Plays from the current seekpoint if stopped */
86 int stream_play(void);
88 /* Pauses playback if playing */
89 int stream_pause(void);
91 /* Resumes playback if paused */
92 int stream_resume(void);
94 /* Stops all streaming activity if playing or paused */
95 int stream_stop(void);
97 /* Point stream at a particular time.
98 * whence = one of SEEK_SET, SEEK_CUR, SEEK_END */
99 int stream_seek(uint32_t time
, int whence
);
101 /* Show/Hide the video image at the current seekpoint */
102 bool stream_show_vo(bool show
);
104 /* Set the visible section of video */
105 void stream_vo_set_clip(const struct vo_rect
*rc
);
107 #ifndef HAVE_LCD_COLOR
108 void stream_gray_show(bool show
);
111 /* Display thumbnail of the current seekpoint */
112 bool stream_display_thumb(const struct vo_rect
*rc
);
114 /* Draw the frame at the current position */
115 bool stream_draw_frame(bool no_prepare
);
117 /* Return video dimensions */
118 bool stream_vo_get_size(struct vo_ext
*sz
);
120 /* Returns the resume time in timestamp ticks */
121 uint32_t stream_get_resume_time(void);
123 /* Returns stream_get_time if no seek is pending or else the
124 last time give to seek */
125 uint32_t stream_get_seek_time(uint32_t *start
);
127 /* Return the absolute stream time in clock ticks - adjusted by
128 * master clock stream via audio timestamps */
129 static inline uint32_t stream_get_time(void)
130 { return pcm_output_get_clock(); }
132 /* Return the absolute clock time in clock ticks - unadjusted */
133 static inline uint32_t stream_get_ticks(uint32_t *start
)
134 { return pcm_output_get_ticks(start
); }
136 /* Returns the current playback status */
137 static inline int stream_status(void)
138 { return stream_mgr
.status
; }
140 /* Wait for a state transistion to complete */
141 void stream_wait_status(void);
143 /* Returns the playback length of the stream */
144 static inline uint32_t stream_get_duration(void)
145 { return str_parser
.duration
; }
147 static inline bool stream_can_seek(void)
148 { return parser_can_seek(); }
150 /* Keep the disk spinning (for seeking and browsing) */
151 static inline void stream_keep_disk_active(void)
153 #ifndef HAVE_FLASH_STORAGE
158 #endif /* STREAM_MGR_H */