[FFmpeg-soc] [soc]: r5308 - in concat/libavformat: avplaylist.c avplaylist.h m3u.c playlist.c playlist.h pls.c utils.c.diff xspf.c
gkovacs
subversion at mplayerhq.hu
Wed Aug 26 10:54:22 CEST 2009
Author: gkovacs
Date: Wed Aug 26 10:54:21 2009
New Revision: 5308
Log:
move split_encoded_string and relative_paths out of public header
Modified:
concat/libavformat/avplaylist.c
concat/libavformat/avplaylist.h
concat/libavformat/m3u.c
concat/libavformat/playlist.c
concat/libavformat/playlist.h
concat/libavformat/pls.c
concat/libavformat/utils.c.diff
concat/libavformat/xspf.c
Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/avplaylist.c Wed Aug 26 10:54:21 2009 (r5308)
@@ -35,77 +35,6 @@
#include "libavutil/avstring.h"
#include "internal.h"
-int av_playlist_split_encodedstring(const char *s,
- const char sep,
- char ***flist_ptr,
- int *len_ptr)
-{
- char c, *ts, **flist;
- int i, len, buflen, *sepidx, *sepidx_tmp;
- sepidx = NULL;
- buflen = len = 0;
- sepidx_tmp = av_fast_realloc(sepidx, &buflen, ++len);
- if (!sepidx_tmp) {
- av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_split_encodedstring\n");
- av_free(sepidx);
- return AVERROR_NOMEM;
- }
- else
- sepidx = sepidx_tmp;
- sepidx[0] = 0;
- ts = s;
- while ((c = *ts++) != 0) {
- if (c == sep) {
- sepidx[len] = ts-s;
- sepidx_tmp = av_fast_realloc(sepidx, &buflen, ++len);
- if (!sepidx_tmp) {
- av_free(sepidx);
- av_log(NULL, AV_LOG_ERROR, "av_fast_realloc error in av_playlist_split_encodedstring\n");
- *flist_ptr = NULL;
- *len_ptr = 0;
- return AVERROR_NOMEM;
- } else
- sepidx = sepidx_tmp;
- }
- }
- sepidx[len] = ts-s;
- ts = s;
- *len_ptr = len;
- *flist_ptr = flist = av_malloc(sizeof(*flist) * (len+1));
- flist[len] = 0;
- for (i = 0; i < len; ++i) {
- flist[i] = av_malloc(sepidx[i+1]-sepidx[i]);
- if (!flist[i]) {
- av_log(NULL, AV_LOG_ERROR, "av_malloc error in av_playlist_split_encodedstring\n");
- *flist_ptr = NULL;
- *len_ptr = 0;
- return AVERROR_NOMEM;
- }
- av_strlcpy(flist[i], ts+sepidx[i], sepidx[i+1]-sepidx[i]);
- }
- av_free(sepidx);
-}
-
-void av_playlist_relative_paths(char **flist,
- int len,
- const char *workingdir)
-{
- int i;
- for (i = 0; i < len; ++i) { // determine if relative paths
- char *full_file_path;
- int workingdir_len, filename_len;
- workingdir_len = strlen(workingdir);
- filename_len = strlen(flist[i]);
- full_file_path = av_malloc(workingdir_len + filename_len + 2);
- av_strlcpy(full_file_path, workingdir, workingdir_len + 1);
- full_file_path[workingdir_len] = '/';
- full_file_path[workingdir_len + 1] = 0;
- av_strlcat(full_file_path, flist[i], workingdir_len + filename_len + 2);
- if (url_exist(full_file_path))
- flist[i] = full_file_path;
- }
-}
-
int av_playlist_add_item(AVPlaylistContext *ctx, const char *itempath)
{
return av_playlist_insert_item(ctx, itempath, ctx->pelist_size);
Modified: concat/libavformat/avplaylist.h
==============================================================================
--- concat/libavformat/avplaylist.h Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/avplaylist.h Wed Aug 26 10:54:21 2009 (r5308)
@@ -49,27 +49,6 @@ typedef struct AVPlaylistContext {
AVFormatContext *master_formatcontext; /**< Parent AVFormatContext of which priv_data is this playlist. NULL if playlist is used standalone. */
} AVPlaylistContext;
-/** @brief Converts a list of mixed relative or absolute paths into all absolute paths.
- * @param flist List of null-terminated strings of relative or absolute paths.
- * @param len Number of paths in flist.
- * @param workingdir Path that strings in flist are relative to.
- */
-void av_playlist_relative_paths(char **flist,
- int len,
- const char *workingdir);
-
-/** @brief Splits a character-delimited string into a list of strings.
- * @param s The input character-delimited string ("one,two,three").
- * @param sep The delimiter character (',').
- * @param flist_ptr Pointer to string list which will be allocated by function.
- * @param len_ptr Number of segments the string was split into.
- * @return Returns 0 upon success, or negative upon failure.
- */
-int av_playlist_split_encodedstring(const char *s,
- const char sep,
- char ***flist_ptr,
- int *len_ptr);
-
/** @brief Creates and adds AVFormatContext for item located at specified path to a AVPlaylistContext.
* @param ctx Pre-allocated AVPlaylistContext to add elements to.
* @param itempath Absolute path to item for which to add a playlist element.
Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/m3u.c Wed Aug 26 10:54:21 2009 (r5308)
@@ -92,7 +92,7 @@ static int m3u_read_header(AVFormatConte
fprintf(stderr, "no playlist items found in %s\n", s->filename);
return AVERROR_EOF;
}
- av_playlist_relative_paths(flist, flist_len, dirname(s->filename));
+ ff_playlist_relative_paths(flist, flist_len, dirname(s->filename));
ctx = av_mallocz(sizeof(*ctx));
if (!ctx) {
av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in m3u_read_header\n");
Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/playlist.c Wed Aug 26 10:54:21 2009 (r5308)
@@ -136,6 +136,77 @@ int ff_playlist_set_streams(AVPlaylistCo
return 0;
}
+int ff_playlist_split_encodedstring(const char *s,
+ const char sep,
+ char ***flist_ptr,
+ int *len_ptr)
+{
+ char c, *ts, **flist;
+ int i, len, buflen, *sepidx, *sepidx_tmp;
+ sepidx = NULL;
+ buflen = len = 0;
+ sepidx_tmp = av_fast_realloc(sepidx, &buflen, ++len);
+ if (!sepidx_tmp) {
+ av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_split_encodedstring\n");
+ av_free(sepidx);
+ return AVERROR_NOMEM;
+ }
+ else
+ sepidx = sepidx_tmp;
+ sepidx[0] = 0;
+ ts = s;
+ while ((c = *ts++) != 0) {
+ if (c == sep) {
+ sepidx[len] = ts-s;
+ sepidx_tmp = av_fast_realloc(sepidx, &buflen, ++len);
+ if (!sepidx_tmp) {
+ av_free(sepidx);
+ av_log(NULL, AV_LOG_ERROR, "av_fast_realloc error in av_playlist_split_encodedstring\n");
+ *flist_ptr = NULL;
+ *len_ptr = 0;
+ return AVERROR_NOMEM;
+ } else
+ sepidx = sepidx_tmp;
+ }
+ }
+ sepidx[len] = ts-s;
+ ts = s;
+ *len_ptr = len;
+ *flist_ptr = flist = av_malloc(sizeof(*flist) * (len+1));
+ flist[len] = 0;
+ for (i = 0; i < len; ++i) {
+ flist[i] = av_malloc(sepidx[i+1]-sepidx[i]);
+ if (!flist[i]) {
+ av_log(NULL, AV_LOG_ERROR, "av_malloc error in av_playlist_split_encodedstring\n");
+ *flist_ptr = NULL;
+ *len_ptr = 0;
+ return AVERROR_NOMEM;
+ }
+ av_strlcpy(flist[i], ts+sepidx[i], sepidx[i+1]-sepidx[i]);
+ }
+ av_free(sepidx);
+}
+
+void ff_playlist_relative_paths(char **flist,
+ int len,
+ const char *workingdir)
+{
+ int i;
+ for (i = 0; i < len; ++i) { // determine if relative paths
+ char *full_file_path;
+ int workingdir_len, filename_len;
+ workingdir_len = strlen(workingdir);
+ filename_len = strlen(flist[i]);
+ full_file_path = av_malloc(workingdir_len + filename_len + 2);
+ av_strlcpy(full_file_path, workingdir, workingdir_len + 1);
+ full_file_path[workingdir_len] = '/';
+ full_file_path[workingdir_len + 1] = 0;
+ av_strlcat(full_file_path, flist[i], workingdir_len + filename_len + 2);
+ if (url_exist(full_file_path))
+ flist[i] = full_file_path;
+ }
+}
+
int ff_playlist_stream_index_from_time(AVPlaylistContext *ctx,
int64_t pts,
int64_t *localpts)
Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/playlist.h Wed Aug 26 10:54:21 2009 (r5308)
@@ -58,6 +58,27 @@ int ff_playlist_populate_context(AVPlayl
*/
int ff_playlist_set_streams(AVPlaylistContext *ctx);
+/** @brief Converts a list of mixed relative or absolute paths into all absolute paths.
+ * @param flist List of null-terminated strings of relative or absolute paths.
+ * @param len Number of paths in flist.
+ * @param workingdir Path that strings in flist are relative to.
+ */
+void ff_playlist_relative_paths(char **flist,
+ int len,
+ const char *workingdir);
+
+/** @brief Splits a character-delimited string into a list of strings.
+ * @param s The input character-delimited string ("one,two,three").
+ * @param sep The delimiter character (',').
+ * @param flist_ptr Pointer to string list which will be allocated by function.
+ * @param len_ptr Number of segments the string was split into.
+ * @return Returns 0 upon success, or negative upon failure.
+ */
+int ff_playlist_split_encodedstring(const char *s,
+ const char sep,
+ char ***flist_ptr,
+ int *len_ptr);
+
/** @brief Calculates the index of the playlist item which would contain the timestamp specified in AV_TIME_BASE units.
* @param ctx AVPlaylistContext within which the list of playlist elements and durations are stored.
* @param pts Timestamp in AV_TIME_BASE.
Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/pls.c Wed Aug 26 10:54:21 2009 (r5308)
@@ -111,7 +111,7 @@ static int pls_read_header(AVFormatConte
fprintf(stderr, "no playlist items found in %s\n", s->filename);
return AVERROR_EOF;
}
- av_playlist_relative_paths(flist, flist_len, dirname(s->filename));
+ ff_playlist_relative_paths(flist, flist_len, dirname(s->filename));
ctx = av_mallocz(sizeof(*ctx));
if (!ctx) {
av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in pls_read_header\n");
Modified: concat/libavformat/utils.c.diff
==============================================================================
--- concat/libavformat/utils.c.diff Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/utils.c.diff Wed Aug 26 10:54:21 2009 (r5308)
@@ -1,5 +1,5 @@
diff --git a/libavformat/utils.c b/libavformat/utils.c
-index 4cec286..e960580 100644
+index 4cec286..544dfbc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -27,6 +27,8 @@
@@ -25,7 +25,7 @@ index 4cec286..e960580 100644
fmt = av_probe_input_format(pd, 0);
}
-+ av_playlist_split_encodedstring(filename, ',', &flist, &flist_len);
++ ff_playlist_split_encodedstring(filename, ',', &flist, &flist_len);
+ if (flist && flist_len > 1) {
+ AVFormatContext *ic = ff_playlist_alloc_concat_formatcontext();
+ if (ic) {
Modified: concat/libavformat/xspf.c
==============================================================================
--- concat/libavformat/xspf.c Wed Aug 26 10:39:09 2009 (r5307)
+++ concat/libavformat/xspf.c Wed Aug 26 10:54:21 2009 (r5308)
@@ -134,7 +134,7 @@ static int xspf_read_header(AVFormatCont
fprintf(stderr, "no playlist items found in %s\n", s->filename);
return AVERROR_EOF;
}
- av_playlist_relative_paths(flist, flist_len, dirname(s->filename));
+ ff_playlist_relative_paths(flist, flist_len, dirname(s->filename));
ctx = av_mallocz(sizeof(*ctx));
if (!ctx) {
av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in xspf_read_header\n");
More information about the FFmpeg-soc
mailing list