Skip to content
Snippets Groups Projects
Commit 15afa396 authored by Nico Sabbi's avatar Nico Sabbi
Browse files

Added definition and utility functions to handle AVProgram(s) in AVFormatContext

Originally committed as revision 10579 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 99904603
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#ifndef AVFORMAT_H #ifndef AVFORMAT_H
#define AVFORMAT_H #define AVFORMAT_H
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(13<<8)+4) #define LIBAVFORMAT_VERSION_INT ((51<<16)+(14<<8)+0)
#define LIBAVFORMAT_VERSION 51.13.4 #define LIBAVFORMAT_VERSION 51.14.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
...@@ -345,6 +345,16 @@ typedef struct AVStream { ...@@ -345,6 +345,16 @@ typedef struct AVStream {
int64_t pts_buffer[MAX_REORDER_DELAY+1]; int64_t pts_buffer[MAX_REORDER_DELAY+1];
} AVStream; } AVStream;
#define AV_PROGRAM_RUNNING 1
typedef struct AVProgram {
int id;
char *provider_name; ///< Network name for DVB streams
char *name; ///< Service name for DVB streams
int flags;
enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
} AVProgram;
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
(streams are added dynamically) */ (streams are added dynamically) */
...@@ -430,6 +440,9 @@ typedef struct AVFormatContext { ...@@ -430,6 +440,9 @@ typedef struct AVFormatContext {
const uint8_t *key; const uint8_t *key;
int keylen; int keylen;
unsigned int nb_programs;
AVProgram **programs;
} AVFormatContext; } AVFormatContext;
typedef struct AVPacketList { typedef struct AVPacketList {
...@@ -647,6 +660,7 @@ void av_close_input_file(AVFormatContext *s); ...@@ -647,6 +660,7 @@ void av_close_input_file(AVFormatContext *s);
* @param id file format dependent stream id * @param id file format dependent stream id
*/ */
AVStream *av_new_stream(AVFormatContext *s, int id); AVStream *av_new_stream(AVFormatContext *s, int id);
AVProgram *av_new_program(AVFormatContext *s, int id);
/** /**
* Set the pts for a given stream. * Set the pts for a given stream.
......
...@@ -2067,6 +2067,11 @@ void av_close_input_file(AVFormatContext *s) ...@@ -2067,6 +2067,11 @@ void av_close_input_file(AVFormatContext *s)
av_free(st->codec); av_free(st->codec);
av_free(st); av_free(st);
} }
for(i=s->nb_programs-1; i>=0; i--) {
av_freep(&s->programs[i]->provider_name);
av_freep(&s->programs[i]->name);
av_freep(&s->programs[i]);
}
flush_packet_queue(s); flush_packet_queue(s);
must_open_file = 1; must_open_file = 1;
if (s->iformat->flags & AVFMT_NOFILE) { if (s->iformat->flags & AVFMT_NOFILE) {
...@@ -2113,6 +2118,43 @@ AVStream *av_new_stream(AVFormatContext *s, int id) ...@@ -2113,6 +2118,43 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
return st; return st;
} }
AVProgram *av_new_program(AVFormatContext *ac, int id)
{
AVProgram *program=NULL;
int i;
#ifdef DEBUG_SI
av_log(ac, AV_LOG_DEBUG, "new_program: id=0x%04x\n", id);
#endif
for(i=0; i<ac->nb_programs; i++)
if(ac->programs[i]->id == id)
program = ac->programs[i];
if(!program){
program = av_mallocz(sizeof(AVProgram));
if (!program)
return NULL;
dynarray_add(&ac->programs, &ac->nb_programs, program);
program->discard = AVDISCARD_NONE;
}
program->id = id;
return program;
}
void av_set_program_name(AVProgram *program, char *provider_name, char *name)
{
assert(!provider_name == !name);
if(name){
av_free(program->provider_name);
av_free(program-> name);
program->provider_name = av_strdup(provider_name);
program-> name = av_strdup( name);
}
}
/************************************************************/ /************************************************************/
/* output media file */ /* output media file */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment