Go to the documentation of this file.
76 #include <libxml/parser.h>
78 #define AVRATIONAL_FORMAT "%d/%d"
79 #define AVRATIONAL_ARG(rational) rational.num, rational.den
132 return strstr(
string,
"://") !=
NULL;
137 return string[0] ==
'/';
143 if (
string[1] ==
':' &&
string[2] ==
'\\')
147 if (
string[1] ==
':' &&
string[2] ==
'/')
151 if (
string[0] ==
'\\' &&
string[1] ==
'\\')
165 if ((
av_reduce(&dst_num, &dst_den,
r.num,
r.den, INT64_MAX) != 1))
187 const char *base_url)
189 xmlNodePtr asset_map_element =
NULL;
190 xmlNodePtr node =
NULL;
191 xmlNodePtr asset_element =
NULL;
192 unsigned long elem_count;
198 asset_map_element = xmlDocGetRootElement(doc);
200 if (!asset_map_element) {
205 if (asset_map_element->type != XML_ELEMENT_NODE ||
av_strcasecmp(asset_map_element->name,
"AssetMap")) {
206 av_log(
s,
AV_LOG_ERROR,
"Unable to parse asset map XML - wrong root node name[%s] type[%d]\n",
207 asset_map_element->name, (
int)asset_map_element->type);
216 elem_count = xmlChildElementCount(node);
217 if (elem_count > UINT32_MAX
218 || asset_map->
asset_count > UINT32_MAX - elem_count)
229 asset_element = xmlFirstElementChild(node);
230 while (asset_element) {
270 asset_element = xmlNextElementSibling(asset_element);
303 const char *base_url;
304 char *tmp_str =
NULL;
334 doc = xmlReadMemory(buf.str, buf.len, url,
NULL, 0);
339 c->asset_locator_map.asset_count, url);
354 if (memcmp(asset_map->
assets[
i].
uuid, uuid, 16) == 0)
355 return &(asset_map->
assets[
i]);
366 int64_t seek_offset = 0;
371 if (track_resource->
ctx) {
378 if (!track_resource->
ctx)
382 #if FF_API_AVFORMAT_IO_CLOSE
384 track_resource->
ctx->io_close =
s->io_close;
437 "Could not seek at %" PRId64
"on %s: %s\n",
464 if (!asset_locator) {
491 vt_ctx.
locator = asset_locator;
492 vt_ctx.
resource = track_file_resource;
549 if (
c->track_count == UINT32_MAX) {
559 c->tracks[
c->track_count++] = track;
574 for (uint32_t
i = 0;
i <
c->track_count;
i++) {
582 first_resource_stream =
c->tracks[
i]->resources[0].ctx->streams[0];
591 asset_stream->
id =
i;
610 if (
c->cpl->main_image_2d_track) {
613 AV_UUID_ARG(
c->cpl->main_image_2d_track->base.id_uuid));
618 for (uint32_t
i = 0;
i <
c->cpl->main_audio_track_count;
i++) {
632 char *asset_map_path;
638 c->interrupt_callback = &
s->interrupt_callback;
656 if (!tcr &&
c->cpl->tc) {
669 if (!
c->asset_map_paths) {
671 if (!
c->asset_map_paths) {
680 asset_map_path =
av_strtok(
c->asset_map_paths,
",", &tmp_str);
681 while (asset_map_path !=
NULL) {
709 for (uint32_t
i =
c->track_count;
i > 0;
i--) {
717 if (
av_cmp_q(
c->tracks[
i - 1]->current_timestamp, minimum_timestamp) <= 0) {
718 track =
c->tracks[
i - 1];
737 "Looking for track %d resource for timestamp = %lf / %lf\n",
802 ", duration=%" PRId64
", stream_index=%d, pos=%" PRId64
868 int64_t skip_samples;
874 if (
ret || skip_samples < 0 || skip_samples > UINT32_MAX) {
881 AV_WL32(side_data + 4, skip_samples);
886 next_timestamp = resource->
end_time;
908 for (uint32_t
i = 0;
i <
c->track_count;
i++) {
920 if (!strstr(p->
buf,
"<CompositionPlaylist"))
926 if (!strstr(p->
buf,
"ContentTitle>"))
939 in_tb.
den * out_tb.
num, INT64_MAX);
940 if (!
ret || dst_den != 1)
947 int64_t ts, int64_t max_ts,
int flags)
956 if (stream_index < 0)
958 av_make_q(
c->cpl->edit_rate.den,
c->cpl->edit_rate.num),
959 &min_ts, &ts, &max_ts);
962 av_make_q(
c->cpl->edit_rate.den,
c->cpl->edit_rate.num),
963 &min_ts, &ts, &max_ts);
975 for (
i = 0;
i <
c->track_count;
i++) {
1003 .
name =
"assetmaps",
1004 .help =
"Comma-separated paths to ASSETMAP files."
1005 "If not specified, the `ASSETMAP.xml` file in the same "
1006 "directory as the CPL is used.",
1007 .offset = offsetof(
IMFContext, asset_map_paths),
1009 .default_val = {.str =
NULL},
#define FF_ENABLE_DEPRECATION_WARNINGS
FFIMFTrackFileResource * resources
Resource elements of the Virtual Track.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_TIMECODE_STR_SIZE
AVRational ts_offset
start_time minus the entry point into the resource (s)
int ffio_copy_url_options(AVIOContext *pb, AVDictionary **avio_opts)
Read url related dictionary options from the AVIOContext and write to the given dictionary.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
static int set_context_streams_from_tracks(AVFormatContext *s)
uint8_t AVUUID[AV_UUID_LEN]
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
static int parse_assetmap(AVFormatContext *s, const char *url)
static int track_index(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *buf, unsigned size)
#define AVERROR_EOF
End of file.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
static int imf_close(AVFormatContext *s)
static IMFAssetLocator * find_asset_map_locator(IMFAssetLocatorMap *asset_map, AVUUID uuid)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_cold void cleanup(FlashSV2Context *s)
AVStream ** streams
A list of all streams in the file.
uint32_t resource_count
Number of Resource elements present in the Virtual Track.
AVRational start_time
inclusive start time of the resource on the CPL timeline (s)
IMFAssetLocatorMap asset_locator_map
static int imf_probe(const AVProbeData *p)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVRational av_sub_q(AVRational b, AVRational c)
Subtract one rational from another.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int nb_channels
Number of channels in this layout.
Callback for checking whether to abort blocking functions.
static int imf_uri_is_unix_abs_path(const char *string)
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
static int coherent_ts(int64_t ts, AVRational in_tb, AVRational out_tb)
#define AVRATIONAL_ARG(rational)
static int imf_uri_is_dos_abs_path(const char *string)
uint32_t resource_count
Number of resources (<= INT32_MAX)
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
void ff_imf_cpl_free(FFIMFCPL *cpl)
Deletes an FFIMFCPL data structure previously instantiated with ff_imf_cpl_alloc().
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
static av_cold int read_close(AVFormatContext *ctx)
uint32_t duration
BaseResourceType/Duration.
xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *name_utf8)
Returns the first child element with the specified local name.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int64_t duration
Decoding: duration of the stream, in stream time base.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
const char * av_dirname(char *path)
Thread safe dirname.
static int open_track_file_resource(AVFormatContext *s, FFIMFTrackFileResource *track_file_resource, IMFVirtualTrackPlaybackCtx *track)
static int imf_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
IMF Composition Playlist Virtual Track that consists of Track File Resources.
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVRational current_timestamp
Current temporal position.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int flags
Flags modifying the (de)muxer behaviour.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static const AVOption imf_options[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
IMFAssetLocator * locator
Location of the resource.
static IMFVirtualTrackPlaybackCtx * get_next_track_with_minimum_timestamp(AVFormatContext *s)
FFIMFTrackFileResource * resource
Underlying IMF CPL resource.
AVFormatContext * ctx
Context associated with the resource.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
This structure contains the data a format has to probe a file.
void ff_rescale_interval(AVRational tb_in, AVRational tb_out, int64_t *min_ts, int64_t *ts, int64_t *max_ts)
Rescales a timestamp and the endpoints of an interval to which the temstamp belongs,...
static int imf_uri_is_url(const char *string)
AVIOInterruptCB * interrupt_callback
static int get_resource_context_for_timestamp(AVFormatContext *s, IMFVirtualTrackPlaybackCtx *track, IMFVirtualTrackResourcePlaybackCtx **resource)
const AVInputFormat ff_imf_demuxer
AVChannelLayout ch_layout
Audio only.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int open_track_resource_context(AVFormatContext *s, IMFVirtualTrackPlaybackCtx *track, int32_t resource_index)
int sample_rate
Audio only.
int64_t nb_frames
number of frames in this stream if known or 0
AVRational end_time
exclusive end time of the resource on the CPL timeline (s)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int imf_read_packet(AVFormatContext *s, AVPacket *pkt)
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVRational edit_rate
BaseResourceType/EditRate.
static void imf_asset_locator_map_deinit(IMFAssetLocatorMap *asset_map)
Free a IMFAssetLocatorMap pointer.
AVUUID track_file_uuid
TrackFileResourceType/TrackFileId.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void imf_asset_locator_map_init(IMFAssetLocatorMap *asset_map)
Initializes an IMFAssetLocatorMap structure.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static int open_cpl_tracks(AVFormatContext *s)
#define AVRATIONAL_FORMAT
uint32_t repeat_count
BaseResourceType/RepeatCount.
int32_t current_resource_index
Index of the current resource in resources, or < 0 if a current resource has yet to be selected.
#define AV_LOG_INFO
Standard information.
int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl)
Parse an IMF Composition Playlist document into the FFIMFCPL data structure.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint32_t entry_point
BaseResourceType/EntryPoint.
static int imf_read_header(AVFormatContext *s)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
static void imf_virtual_track_playback_context_deinit(IMFVirtualTrackPlaybackCtx *track)
int32_t index
Track index in playlist.
static int parse_imf_asset_map_from_xml_dom(AVFormatContext *s, xmlDocPtr doc, IMFAssetLocatorMap *asset_map, const char *base_url)
Parse a ASSETMAP XML file to extract the UUID-URI mapping of assets.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int imf_time_to_ts(int64_t *ts, AVRational t, AVRational time_base)
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
int id
Format-specific stream ID.
IMF Asset locator map Results from the parsing of one or more ASSETMAP XML files.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVRational duration
Overall duration.
unsigned int resources_alloc_sz
Size of the buffer holding the resource.
IMF Composition Playlist Track File Resource.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
static int open_virtual_track(AVFormatContext *s, FFIMFTrackFileVirtualTrack *virtual_track, int32_t track_index)
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static const AVClass imf_class
#define FF_DISABLE_DEPRECATION_WARNINGS
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
static int read_probe(const AVProbeData *p)
IMFVirtualTrackPlaybackCtx ** tracks
int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid)
Reads a UUID from an XML element.
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int64_t pos
byte position in stream, -1 if unknown
int(* io_close2)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
#define flags(name, subs,...)
IMF Composition Playlist.
Public header file for the processing of Interoperable Master Format (IMF) packages.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
IMFVirtualTrackResourcePlaybackCtx * resources
Buffer holding the resources.
int pts_wrap_bits
Number of bits in timestamps.
AVRational time_base
Time base of the packet's timestamps.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.