[FFmpeg-soc] [soc]: r5193 - in concat/libavformat: playlist.c playlist.h

gkovacs subversion at mplayerhq.hu
Thu Aug 20 15:02:00 CEST 2009


Author: gkovacs
Date: Thu Aug 20 15:01:59 2009
New Revision: 5193

Log:
added ff_playlist_from_filelist and ff_playlist_formatcontext_from_filelist

Modified:
   concat/libavformat/playlist.c
   concat/libavformat/playlist.h

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Thu Aug 20 13:59:38 2009	(r5192)
+++ concat/libavformat/playlist.c	Thu Aug 20 15:01:59 2009	(r5193)
@@ -33,6 +33,7 @@
 #include "avformat.h"
 #include "playlist.h"
 #include "internal.h"
+#include "concat.h"
 
 AVFormatContext *ff_playlist_alloc_formatcontext(char *filename)
 {
@@ -95,6 +96,23 @@ PlaylistContext *ff_playlist_get_context
         return NULL;
 }
 
+AVFormatContext *ff_playlist_formatcontext_from_filelist(const char **flist, int len)
+{
+    PlaylistContext *ctx;
+    AVFormatContext *ic;
+    ctx = ff_playlist_from_filelist(flist, len);
+    if (!ctx) {
+        av_log(NULL, AV_LOG_ERROR, "failed to create PlaylistContext in ff_playlist_formatcontext_from_filelist\n");
+        return NULL;
+    }
+    avformat_alloc_context();
+    ic->iformat = ff_concat_alloc_demuxer();
+    ic->priv_data = ctx;
+    ff_playlist_populate_context(ctx, ctx->pe_curidx);
+    ff_playlist_set_streams(ic);
+    return ic;
+}
+
 void ff_playlist_split_encodedstring(const char *s,
                                      const char sep,
                                      char ***flist_ptr,
@@ -133,6 +151,20 @@ void ff_playlist_split_encodedstring(con
     av_free(sepidx);
 }
 
+PlaylistContext *ff_playlist_from_filelist(const char **flist, int len)
+{
+    int i;
+    PlaylistContext *ctx;
+    ctx = av_mallocz(sizeof(*ctx));
+    if (!ctx) {
+        av_log(NULL, AV_LOG_ERROR, "av_mallocz error in ff_playlist_from_encodedstring\n");
+        return NULL;
+    }
+    for (i = 0; i < len; ++i)
+        ff_playlist_add_path(ctx, flist[i]);
+    return ctx;
+}
+
 PlaylistContext *ff_playlist_from_encodedstring(const char *s, const char sep)
 {
     PlaylistContext *ctx;
@@ -145,13 +177,8 @@ PlaylistContext *ff_playlist_from_encode
         av_free(flist);
         return NULL;
     }
-    ctx = av_mallocz(sizeof(*ctx));
-    if (!ctx) {
-        av_log(NULL, AV_LOG_ERROR, "av_mallocz error in ff_playlist_from_encodedstring\n");
-        return NULL;
-    }
-    for (i = 0; i < len; ++i)
-        ff_playlist_add_path(ctx, flist[i]);
+    ctx = ff_playlist_from_filelist(flist, len);
+    av_free(flist);
     return ctx;
 }
 

Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h	Thu Aug 20 13:59:38 2009	(r5192)
+++ concat/libavformat/playlist.h	Thu Aug 20 15:01:59 2009	(r5193)
@@ -70,10 +70,18 @@ void ff_playlist_populate_context(Playli
  */
 void ff_playlist_set_streams(AVFormatContext *s);
 
+/** @fn ff_playlist_formatcontext_from_filelist(const char **flist, int len)
+ *  @brief Allocates and populates a new AVFormatContext for a concat-type demuxer.
+ *  @param flist List of filenames from which to construct the playlist.
+ *  @param len Length of filename list.
+ *  @return Returns NULL if failed, or AVFormatContext if succeeded.
+ */
+AVFormatContext *ff_playlist_formatcontext_from_filelist(const char **flist, int len);
+
 /** @fn PlaylistContext* ff_playlist_get_context(AVFormatContext *ic)
  *  @brief Returns PlaylistContext continaed within a concat-type demuxer.
  *  @param ic AVFormatContext of the concat-type demuxer, which contains the PlaylistContext.
- *  @return Returnes NULL if failed (not concat-type demuxer or Playlist not yet allocated), or PlaylistContext if succeeded.
+ *  @return Returns NULL if failed (not concat-type demuxer or Playlist not yet allocated), or PlaylistContext if succeeded.
  */
 PlaylistContext* ff_playlist_get_context(AVFormatContext *ic);
 
@@ -99,6 +107,14 @@ void ff_playlist_split_encodedstring(con
                                      char ***flist_ptr,
                                      int *len_ptr);
 
+/** @fn PlaylistContext *ff_playlist_from_filelist(const char **flist, int len)
+ *  @brief Allocates and returns a PlaylistContext with playlist elements specified by a file list.
+ *  @param flist List of filenames from which to construct the playlist.
+ *  @param len Length of filename list.
+ *  @return Returns the allocated PlaylistContext.
+ */
+PlaylistContext *ff_playlist_from_filelist(const char **flist, int len);
+
 /** @fn PlaylistContext *ff_playlist_from_encodedstring(char *s, char sep)
  *  @brief Allocates and returns a PlaylistContext with playlist elements specified by a character-delimited string.
  *  @param s The input character-delimited string ("one,two,three").


More information about the FFmpeg-soc mailing list