- offset_t pos;
- int i;
-
- pos = url_ftell(pb);
- ctx->umf_media_offset = pos - ctx->umf_start_offset;
- for (i = 0; i < ctx->fc->nb_streams; ++i) {
- GXFStreamContext *sc = &ctx->streams[i];
- char buffer[88];
- offset_t startpos, curpos;
- int path_size = strlen(ES_NAME_PATTERN);
-
- startpos = url_ftell(pb);
- put_le16(pb, 0); /* length */
- put_le16(pb, sc->media_info);
- put_le16(pb, 0); /* reserved */
- put_le16(pb, 0); /* reserved */
- put_le32(pb, ctx->nb_frames);
- put_le32(pb, 0); /* attributes rw, ro */
- put_le32(pb, 0); /* mark in */
- put_le32(pb, ctx->nb_frames); /* mark out */
- strncpy(buffer, ES_NAME_PATTERN, path_size);
- put_buffer(pb, (uint8_t *)buffer, path_size);
- put_be16(pb, sc->media_info);
- put_buffer(pb, (uint8_t *)buffer + path_size + 2, 88 - path_size - 2);
- put_le32(pb, sc->track_type);
- put_le32(pb, sc->sample_rate);
- put_le32(pb, sc->sample_size);
- put_le32(pb, 0); /* reserved */
- switch (sc->codec->codec_id) {
- case CODEC_ID_MPEG2VIDEO:
- gxf_write_umf_media_mpeg(pb, sc);
- break;
- case CODEC_ID_PCM_S16LE:
- gxf_write_umf_media_audio(pb, sc);
- break;
- case CODEC_ID_DVVIDEO:
- gxf_write_umf_media_dv(pb, sc);
- break;
- default:
+ GXFContext *gxf = s->priv_data;
+ AVIOContext *pb = s->pb;
+ int64_t pos;
+ int i, j;
+
+ pos = avio_tell(pb);
+ gxf->umf_media_offset = pos - gxf->umf_start_offset;
+ for (i = 0; i <= s->nb_streams; ++i) {
+ GXFStreamContext *sc;
+ int64_t startpos, curpos;
+
+ if (i == s->nb_streams)
+ sc = &gxf->timecode_track;
+ else
+ sc = s->streams[i]->priv_data;
+
+ startpos = avio_tell(pb);
+ avio_wl16(pb, 0); /* length */
+ avio_wl16(pb, sc->media_info);
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl32(pb, gxf->nb_fields);
+ avio_wl32(pb, 0); /* attributes rw, ro */
+ avio_wl32(pb, 0); /* mark in */
+ avio_wl32(pb, gxf->nb_fields); /* mark out */
+ avio_write(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
+ avio_wb16(pb, sc->media_info);
+ for (j = strlen(ES_NAME_PATTERN)+2; j < 88; j++)
+ avio_w8(pb, 0);
+ avio_wl32(pb, sc->track_type);
+ avio_wl32(pb, sc->sample_rate);
+ avio_wl32(pb, sc->sample_size);
+ avio_wl32(pb, 0); /* reserved */
+
+ if (sc == &gxf->timecode_track)