1 /*
2  *			GPAC - Multimedia Framework C SDK
3  *
4  *			Authors: Arash Shafiei
5  *			Copyright (c) Telecom ParisTech 2000-2013
6  *					All rights reserved
7  *
8  *  This file is part of GPAC / dashcast
9  *
10  *  GPAC is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU Lesser General Public License as published by
12  *  the Free Software Foundation; either version 2, or (at your option)
13  *  any later version.
14  *
15  *  GPAC is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU Lesser General Public License for more details.
19  *
20  *  You should have received a copy of the GNU Lesser General Public
21  *  License along with this library; see the file COPYING.  If not, write to
22  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  */
25 
26 #ifndef VIDEO_DECODER_H_
27 #define VIDEO_DECODER_H_
28 
29 #include "video_data.h"
30 
31 #include "libavformat/avformat.h"
32 #include "libavdevice/avdevice.h"
33 
34 
35 /*
36  * The structure which keeps the data of
37  * input video file.
38  */
39 typedef struct {
40 	/* Format context structure provided by avlib to open and read from a media file. */
41 	AVFormatContext *av_fmt_ctx;
42 	/* A reference counter on the format context (may be shared with other sources). Currently redundant with av_pkt_list non-NULLness. */
43 	int av_fmt_ctx_ref_cnt;
44 	/* A list of AVPackets and return value to be processed: when this parameter is non-null,
45 	 * the video thread makes the demux and pushes the packets. Packets must be freed when retrieved.*/
46 	GF_List  *av_pkt_list;
47 	GF_Mutex *av_pkt_list_mutex;
48 	/* The index of the video stream in the file. */
49 	int vstream_idx;
50 	/* video width, height, and pixel format. */
51 	int width;
52 	int height;
53 	int pix_fmt;
54 	AVRational sar;
55 
56 	int mode;
57 	int no_loop, nb_consumers;
58 
59 	u32 frame_decoded;
60 	u32 pts_init;
61 	u64 first_pts, prev_pts, pts_dur_estimate, sync_tolerance;
62 	u64 utc_at_init;
63 } VideoInputFile;
64 
65 /*
66  * Open the input video
67  *
68  * @param cmd_data [in] contains information about the file name
69  * and the video format.
70  *
71  * @param video_input_file [out] pointer to the structure which we want to
72  * open the file
73  *
74  * @return 0 on success -1 on failure.
75  */
76 int dc_video_decoder_open(VideoInputFile *video_input_file, VideoDataConf *video_data_conf, int mode, int no_loop, int nb_consumers);
77 
78 /*
79  * Read and decode video and put decoded frames on circular buffer
80  *
81  * @param video_input_file [in] contains info on input video.
82  * @param video_input_data [out] the decoded samples will be put
83  * on the circular buffer of this parameter.
84  *
85  * @return 0 on success, -1 on failure, -2 on EOF (end of the file)
86  */
87 int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *video_input_data, int source_number, int use_source_timing, int is_live_capture, const int *exit_signal_addr);
88 
89 /*
90  * Close the input video
91  *
92  * @param video_input_file [in] the video file to be closed
93  *
94  */
95 void dc_video_decoder_close(VideoInputFile *);
96 
97 #endif /* VIDEO_DECODER_H_ */
98