Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix avformat struct definitions #153

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 12 additions & 50 deletions httplivestreaming.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,65 +31,35 @@
typedef struct MpegTSSection {
int pid;
int cc;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 57, 100)
int discontinuity;
#endif
void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
void *opaque;
} MpegTSSection;

typedef struct MpegTSService {
MpegTSSection pmt; /* MPEG2 pmt table context */
int sid; /* service ID */
char *name;
char *provider_name;
int pcr_pid;
int pcr_packet_count;
int pcr_packet_period;
//
// NOTE: there are more fields but we don't need them
//
} MpegTSService;

typedef struct MpegTSWrite {
const AVClass *av_class;
MpegTSSection pat; /* MPEG2 pat table */
MpegTSSection sdt; /* MPEG2 sdt table context */
MpegTSService **services;
int sdt_packet_count;
int sdt_packet_period;
int pat_packet_count;
int pat_packet_period;
int nb_services;
int onid;
int tsid;
int64_t first_pcr;
int mux_rate; ///< set to 1 when VBR
int pes_payload_size;

int transport_stream_id;
int original_network_id;
int service_id;

int pmt_start_pid;
int start_pid;
int m2ts_mode;

int reemit_pat_pmt; // backward compatibility

int flags;
int copyts;
int tables_version;

int omit_video_pes_length;
//
// NOTE: there are more fields but we don't need them
//
} MpegTSWrite;

typedef struct MpegTSWriteStream {
struct MpegTSService *service;
int pid; /* stream associated pid */
int cc;
int payload_size;
int first_pts_check; ///< first pts check needed
int prev_payload_key;
int64_t payload_pts;
int64_t payload_dts;
int payload_flags;
uint8_t *payload;
AVFormatContext *amux;
//
// NOTE: there are more fields but we don't need them
//
} MpegTSWriteStream;
/** END OF COPY **/

Expand Down Expand Up @@ -308,7 +278,6 @@ int hls_write_packet(HTTPLiveStreaming *hls, AVPacket *pkt, int split) {
MpegTSWriteStream *ts_st;
uint8_t pat_cc;
uint8_t sdt_cc;
uint8_t pmt_cc;
int *stream_cc;
int nb_streams;
int i;
Expand Down Expand Up @@ -336,7 +305,6 @@ int hls_write_packet(HTTPLiveStreaming *hls, AVPacket *pkt, int split) {
ts = hls->format_ctx->priv_data;
pat_cc = ts->pat.cc;
sdt_cc = ts->sdt.cc;
pmt_cc = 15;

nb_streams = hls->format_ctx->nb_streams;
stream_cc = malloc(sizeof(int) * nb_streams);
Expand All @@ -347,9 +315,6 @@ int hls_write_packet(HTTPLiveStreaming *hls, AVPacket *pkt, int split) {
for (i = 0; i < nb_streams; i++) {
ts_st = hls->format_ctx->streams[i]->priv_data;
stream_cc[i] = ts_st->cc;
if (i == 0) {
Copy link
Contributor Author

@marler8997 marler8997 Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I don't really know what these 3 lines or the 3 lines below (369-371) were for. They just had to be removed because there's no references to a service structure in ts_st, so I just removed them. Feel free to enlighten me if this is incorrect.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code was to retain the value of continuity counter for Program Map Table (PID 4096) between two consecutive *.ts files. I've added the code for it at commit 6684cfe.

pmt_cc = ts_st->service->pmt.cc;
}
}

mpegts_close_stream(hls->format_ctx);
Expand All @@ -366,9 +331,6 @@ int hls_write_packet(HTTPLiveStreaming *hls, AVPacket *pkt, int split) {
for (i = 0; i < nb_streams; i++) {
ts_st = hls->format_ctx->streams[i]->priv_data;
ts_st->cc = stream_cc[i];
if (i == 0) {
ts_st->service->pmt.cc = pmt_cc;
}
}
free(stream_cc);
}
Expand Down