Revision 445996aa libavformat/mpegtsenc.c

View differences:

libavformat/mpegtsenc.c
21 21

  
22 22
#include "libavutil/bswap.h"
23 23
#include "libavutil/crc.h"
24
#include "libavutil/opt.h"
24 25
#include "libavcodec/mpegvideo.h"
25 26
#include "avformat.h"
26 27
#include "internal.h"
......
64 65
    int tsid;
65 66
    int64_t first_pcr;
66 67
    int mux_rate; ///< set to 1 when VBR
68

  
69
    int transport_stream_id;
70
    int original_network_id;
71
    int service_id;
72

  
73
    int pmt_start_pid;
74
    int start_pid;
67 75
} MpegTSWrite;
68 76

  
77
static const AVOption options[] = {
78
    { "mpegts_transport_stream_id", "Set transport_stream_id field.",
79
      offsetof(MpegTSWrite, transport_stream_id), FF_OPT_TYPE_INT, 0x0001, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
80
    { "mpegts_original_network_id", "Set original_network_id field.",
81
      offsetof(MpegTSWrite, original_network_id), FF_OPT_TYPE_INT, 0x0001, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
82
    { "mpegts_service_id", "Set service_id field.",
83
      offsetof(MpegTSWrite, service_id), FF_OPT_TYPE_INT, 0x0001, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
84
    { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
85
      offsetof(MpegTSWrite, pmt_start_pid), FF_OPT_TYPE_INT, 0x1000, 0x1000, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM},
86
    { "mpegts_start_pid", "Set the first pid.",
87
      offsetof(MpegTSWrite, start_pid), FF_OPT_TYPE_INT, 0x0100, 0x0100, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM},
88
    { NULL },
89
};
90

  
91
static const AVClass mpegts_muxer_class = {
92
    "MPEGTS muxer",
93
    av_default_item_name,
94
    options,
95
    LIBAVUTIL_VERSION_INT,
96
};
97

  
69 98
/* NOTE: 4 bytes must be left at the end for the crc32 */
70 99
static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
71 100
{
......
152 181
/*********************************************/
153 182
/* mpegts writer */
154 183

  
155
#define DEFAULT_PMT_START_PID   0x1000
156
#define DEFAULT_START_PID       0x0100
157 184
#define DEFAULT_PROVIDER_NAME   "FFmpeg"
158 185
#define DEFAULT_SERVICE_NAME    "Service01"
159 186

  
160
/* default network id, transport stream and service identifiers */
161
#define DEFAULT_ONID            0x0001
162
#define DEFAULT_TSID            0x0001
163
#define DEFAULT_SID             0x0001
164

  
165 187
/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
166 188
#define DEFAULT_PES_HEADER_FREQ 16
167 189
#define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
......
374 396
    service = av_mallocz(sizeof(MpegTSService));
375 397
    if (!service)
376 398
        return NULL;
377
    service->pmt.pid = DEFAULT_PMT_START_PID + ts->nb_services - 1;
399
    service->pmt.pid = ts->pmt_start_pid + ts->nb_services;
378 400
    service->sid = sid;
379 401
    service->provider_name = av_strdup(provider_name);
380 402
    service->name = av_strdup(name);
......
401 423
    const char *provider_name;
402 424
    int *pids;
403 425

  
404
    ts->tsid = DEFAULT_TSID;
405
    ts->onid = DEFAULT_ONID;
426
    ts->tsid = ts->transport_stream_id;
427
    ts->onid = ts->original_network_id;
406 428
    /* allocate a single DVB service */
407 429
    title = av_metadata_get(s->metadata, "service_name", NULL, 0);
408 430
    if (!title)
......
410 432
    service_name = title ? title->value : DEFAULT_SERVICE_NAME;
411 433
    provider = av_metadata_get(s->metadata, "service_provider", NULL, 0);
412 434
    provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
413
    service = mpegts_add_service(ts, DEFAULT_SID, provider_name, service_name);
435
    service = mpegts_add_service(ts, ts->service_id, provider_name, service_name);
414 436
    service->pmt.write_packet = section_write_packet;
415 437
    service->pmt.opaque = s;
416 438
    service->pmt.cc = 15;
......
440 462
        /* MPEG pid values < 16 are reserved. Applications which set st->id in
441 463
         * this range are assigned a calculated pid. */
442 464
        if (st->id < 16) {
443
            ts_st->pid = DEFAULT_START_PID + i;
465
            ts_st->pid = ts->start_pid + i;
444 466
        } else if (st->id < 0x1FFF) {
445 467
            ts_st->pid = st->id;
446 468
        } else {
......
964 986
    mpegts_write_header,
965 987
    mpegts_write_packet,
966 988
    mpegts_write_end,
989
    .priv_class = &mpegts_muxer_class,
967 990
};

Also available in: Unified diff