Skip to content

Commit c9d270f

Browse files
committed
refine code for ossrs#250, ts remux
1 parent e9ed62e commit c9d270f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

trunk/src/app/srs_app_mpegts_udp.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ using namespace std;
3232
#include <srs_kernel_error.hpp>
3333
#include <srs_kernel_log.hpp>
3434
#include <srs_app_config.hpp>
35-
36-
// Transport Stream packets are 188 bytes in length.
37-
#define TS_PACKET_SIZE 188
35+
#include <srs_kernel_ts.hpp>
3836

3937
#ifdef SRS_AUTO_STREAM_CASTER
4038

@@ -55,14 +53,14 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf)
5553
int peer_port = ntohs(from->sin_port);
5654

5755
// drop ts packet when size not modulus by 188
58-
if (nb_buf < TS_PACKET_SIZE || (nb_buf % TS_PACKET_SIZE) != 0) {
56+
if (nb_buf < SRS_TS_PACKET_SIZE || (nb_buf % SRS_TS_PACKET_SIZE) != 0) {
5957
srs_warn("udp: drop %s:%d packet %d bytes", peer_ip.c_str(), peer_port, nb_buf);
6058
return ret;
6159
}
6260
srs_info("udp: got %s:%d packet %d bytes", peer_ip.c_str(), peer_port, nb_buf);
6361

6462
// process each ts packet
65-
for (int i = 0; i < nb_buf; i += TS_PACKET_SIZE) {
63+
for (int i = 0; i < nb_buf; i += SRS_TS_PACKET_SIZE) {
6664
char* ts_packet = buf + i;
6765
if ((ret = on_ts_packet(ts_packet)) != ERROR_SUCCESS) {
6866
srs_warn("mpegts: ignore ts packet error. ret=%d", ret);

trunk/src/kernel/srs_kernel_ts.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ class SrsMpegtsWriter
254254
*p++ = header_size;
255255

256256
// pts; // 33bits
257-
p = write_pts(p, flags >> 6, frame->pts + SRS_AUTO_HLS_DELAY);
257+
p = write_dts_pts(p, flags >> 6, frame->pts + SRS_AUTO_HLS_DELAY);
258258

259259
// dts; // 33bits
260260
if (frame->dts != frame->pts) {
261-
p = write_pts(p, 1, frame->dts + SRS_AUTO_HLS_DELAY);
261+
p = write_dts_pts(p, 1, frame->dts + SRS_AUTO_HLS_DELAY);
262262
}
263263
}
264264

@@ -344,7 +344,7 @@ class SrsMpegtsWriter
344344

345345
return p;
346346
}
347-
static char* write_pts(char* p, u_int8_t fb, int64_t pts)
347+
static char* write_dts_pts(char* p, u_int8_t fb, int64_t pts)
348348
{
349349
int32_t val;
350350

trunk/src/kernel/srs_kernel_ts.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class SrsAvcAacCodec;
3939
class SrsCodecSample;
4040
class SrsSimpleBuffer;
4141

42+
// Transport Stream packets are 188 bytes in length.
43+
#define SRS_TS_PACKET_SIZE 188
44+
4245
// @see: ngx_rtmp_SrsMpegtsFrame_t
4346
class SrsMpegtsFrame
4447
{

0 commit comments

Comments
 (0)