@@ -1,3 +1,16 @@
+# use pkg-config for getting CFLAGS and LDLIBS
+FFMPEG_LIBS= libavdevice \
+ libavformat \
+ libavfilter \
+ libavcodec \
+ libswresample \
+ libswscale \
+ libavutil \
+
+CFLAGS += -Wall -g
+CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
+LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
+
EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
@@ -19,6 +32,7 @@ EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
+EXAMPLES-$(CONFIG_SAMPLE_EXAMPLE) += sample
EXAMPLES := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
EXAMPLES_G := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
@@ -39,6 +39,15 @@ struct buffer_data {
size_t size; ///< size left in the buffer
};
+static int isLocal(char *url)
+{
+ if (av_strstart(url, "http://", NULL) || av_strstart(url, "https://", NULL))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
{
struct buffer_data *bd = (struct buffer_data *)opaque;
@@ -78,7 +87,28 @@ int main(int argc, char *argv[])
av_register_all();
/* slurp file content into buffer */
- ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
+
+ if (isLocal(input_filename) == TRUE)
+ {
+ ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
+ }
+ else
+ {
+ AVIOContext *in = NULL;
+
+ ret = avio_open2(&in, input_filename, AVIO_FLAG_READ, NULL, NULL);
+
+ buffer_size = avio_size(in);
+
+ if (buffer_size <= 0) {
+ buffer_size = 8 * 1024;
+ }
+
+ if (buffer = av_mallocz(buffer_size) == NULL) {
+ return AVERROR(ENOMEM);
+ }
+ buffer_size = avio_read(in, buffer, buffer_size);
+ }
if (ret < 0)
goto end;
@@ -21,7 +21,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include "libavcodec/internal.h"
+#include "libavutil/reverse.h"
#include "libavcodec/mathops.h"
#include "avcodec.h"
#include "dsd_tablegen.h"
@@ -24,6 +24,8 @@
* @author Konstantin Shishkov
*/
+#include "libavutil/reverse.h"
+
#include "config.h"
#if CONFIG_ZLIB
#include <zlib.h>
@@ -21,6 +21,8 @@
#include "libavutil/mathematics.h"
#include "libavutil/imgutils.h"
+#include "libavutil/intmath.h"
+
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
@@ -43,9 +43,9 @@ const struct fmt_map ff_fmt_conversion_table[] = {
{ AV_PIX_FMT_NV12, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12 },
{ AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_MJPEG },
{ AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_JPEG },
-#ifdef V4L2_PIX_FMT_H264
+//#ifdef V4L2_PIX_FMT_H264
{ AV_PIX_FMT_NONE, AV_CODEC_ID_H264, V4L2_PIX_FMT_H264 },
-#endif
+//#endif
#ifdef V4L2_PIX_FMT_MPEG4
{ AV_PIX_FMT_NONE, AV_CODEC_ID_MPEG4, V4L2_PIX_FMT_MPEG4 },
#endif
@@ -522,6 +522,22 @@ static enum AVMediaType get_content_type(xmlNodePtr node)
return type;
}
+static struct fragment * getFragment(char *range)
+{
+ struct fragment * seg = av_mallocz(sizeof(struct fragment));
+
+ memset(seg, 0, sizeof(struct fragment));
+ seg->size = -1;
+ if (range) {
+ char *str_end_offset;
+ char *str_offset = av_strtok(range, "-", &str_end_offset);
+ seg->url_offset = strtoll(str_offset, NULL, 10);
+ seg->size = strtoll(str_end_offset, NULL, 10) -seg->url_offset;
+ }
+
+ return seg;
+}
+
static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representation *rep,
xmlNodePtr fragmenturl_node,
xmlNodePtr *baseurl_nodes,
@@ -530,11 +546,13 @@ static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
{
char *initialization_val = NULL;
char *media_val = NULL;
+ char *range_val = NULL;
if (!av_strcasecmp(fragmenturl_node->name, (const char *)"Initialization")) {
initialization_val = xmlGetProp(fragmenturl_node, "sourceURL");
- if (initialization_val) {
- rep->init_section = av_mallocz(sizeof(struct fragment));
+ range_val = xmlGetProp(fragmenturl_node, "range");
+ if (initialization_val || range_val) {
+ rep->init_section = getFragment(range_val);// byte range on
if (!rep->init_section) {
xmlFree(initialization_val);
return AVERROR(ENOMEM);
@@ -550,11 +568,13 @@ static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
}
rep->init_section->size = -1;
xmlFree(initialization_val);
+ xmlFree(range_val);
}
} else if (!av_strcasecmp(fragmenturl_node->name, (const char *)"SegmentURL")) {
media_val = xmlGetProp(fragmenturl_node, "media");
- if (media_val) {
- struct fragment *seg = av_mallocz(sizeof(struct fragment));
+ range_val = xmlGetProp(fragmenturl_node, "mediaRange");
+ if (media_val || range_val) {
+ struct fragment *seg = getFragment(range_val);// byte range on
if (!seg) {
xmlFree(media_val);
return AVERROR(ENOMEM);
@@ -571,12 +591,12 @@ static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
seg->size = -1;
dynarray_add(&rep->fragments, &rep->n_fragments, seg);
xmlFree(media_val);
+ xmlFree(range_val);
}
}
return 0;
}
-
static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representation *rep,
xmlNodePtr fragment_timeline_node)
{