blob: 8acdd78e5d329d14ac5675c29de3138d41dba4c8 [file] [log] [blame]
Tristan Matthews0a329cc2013-07-17 13:20:14 -04001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJMEDIA_AVI_STREAM_H__
20#define __PJMEDIA_AVI_STREAM_H__
21
22/**
23 * @file avi_stream.h
24 * @brief AVI file player.
25 */
26#include <pjmedia/port.h>
27
28
29
30PJ_BEGIN_DECL
31
32
33/**
34 * @defgroup PJMEDIA_FILE_PLAY AVI File Player
35 * @ingroup PJMEDIA_PORT
36 * @brief Video and audio playback from AVI file
37 * @{
38 */
39
40/**
41 * AVI file player options.
42 */
43enum pjmedia_avi_file_player_option
44{
45 /**
46 * Tell the file player to return NULL frame when the whole
47 * file has been played.
48 */
49 PJMEDIA_AVI_FILE_NO_LOOP = 1
50};
51
52/**
53 * AVI stream data type.
54 */
55typedef pjmedia_port pjmedia_avi_stream;
56
57/**
58 * Opaque data type for AVI streams. AVI streams is a collection of
59 * zero or more AVI stream.
60 */
61typedef struct pjmedia_avi_streams pjmedia_avi_streams;
62
63/**
64 * Create avi streams to play an AVI file. AVI player supports
65 * reading AVI file with uncompressed video format and
66 * 16 bit PCM or compressed G.711 A-law/U-law audio format.
67 *
68 * @param pool Pool to create the streams.
69 * @param filename File name to open.
70 * @param flags Avi streams creation flags.
71 * @param p_streams Pointer to receive the avi streams instance.
72 *
73 * @return PJ_SUCCESS on success.
74 */
75PJ_DECL(pj_status_t)
76pjmedia_avi_player_create_streams(pj_pool_t *pool,
77 const char *filename,
78 unsigned flags,
79 pjmedia_avi_streams **p_streams);
80
81/**
82 * Get the number of AVI stream.
83 *
84 * @param streams The AVI streams.
85 *
86 * @return The number of AVI stream.
87 */
88PJ_DECL(unsigned)
89pjmedia_avi_streams_get_num_streams(pjmedia_avi_streams *streams);
90
91/**
92 * Return the idx-th stream of the AVI streams.
93 *
94 * @param streams The AVI streams.
95 * @param idx The stream index.
96 *
97 * @return The AVI stream or NULL if it does not exist.
98 */
99PJ_DECL(pjmedia_avi_stream *)
100pjmedia_avi_streams_get_stream(pjmedia_avi_streams *streams,
101 unsigned idx);
102
103/**
104 * Return an AVI stream with a certain media type from the AVI streams.
105 *
106 * @param streams The AVI streams.
107 * @param start_idx The starting index.
108 * @param media_type The media type of the stream.
109 *
110 * @return The AVI stream or NULL if it does not exist.
111 */
112PJ_DECL(pjmedia_avi_stream *)
113pjmedia_avi_streams_get_stream_by_media(pjmedia_avi_streams *streams,
114 unsigned start_idx,
115 pjmedia_type media_type);
116
117/**
118 * Return the media port of an AVI stream.
119 *
120 * @param stream The AVI stream.
121 *
122 * @return The media port.
123 */
124PJ_INLINE(pjmedia_port *)
125pjmedia_avi_stream_get_port(pjmedia_avi_stream *stream)
126{
127 return (pjmedia_port *)stream;
128}
129
130/**
131 * Get the data length, in bytes.
132 *
133 * @param stream The AVI stream.
134 *
135 * @return The length of the data, in bytes. Upon error it will
136 * return negative value.
137 */
138PJ_DECL(pj_ssize_t) pjmedia_avi_stream_get_len(pjmedia_avi_stream *stream);
139
140
141/**
142 * Register a callback to be called when the file reading has reached the
143 * end of file. If the file is set to play repeatedly, then the callback
144 * will be called multiple times. Note that only one callback can be
145 * registered for each AVI stream.
146 *
147 * @param stream The AVI stream.
148 * @param user_data User data to be specified in the callback
149 * @param cb Callback to be called. If the callback returns non-
150 * PJ_SUCCESS, the playback will stop. Note that if
151 * application destroys the file port in the callback,
152 * it must return non-PJ_SUCCESS here.
153 *
154 * @return PJ_SUCCESS on success.
155 */
156PJ_DECL(pj_status_t)
157pjmedia_avi_stream_set_eof_cb(pjmedia_avi_stream *stream,
158 void *user_data,
159 pj_status_t (*cb)(pjmedia_avi_stream *stream,
160 void *usr_data));
161
162/**
163 * @}
164 */
165
166
167PJ_END_DECL
168
169
170#endif /* __PJMEDIA_AVI_STREAM_H__ */