mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
UTest: Fix utest warnings.
This commit is contained in:
parent
cfbbe3044f
commit
9c81a0e1bd
8 changed files with 603 additions and 560 deletions
|
@ -7246,20 +7246,11 @@ string SrsConfig::get_https_api_listen()
|
||||||
{
|
{
|
||||||
SRS_OVERWRITE_BY_ENV_STRING("srs.http_api.https.listen");
|
SRS_OVERWRITE_BY_ENV_STRING("srs.http_api.https.listen");
|
||||||
|
|
||||||
#ifdef SRS_UTEST
|
// We should not use static default, because we need to reset for different use scenarios.
|
||||||
// We should not use static default, because we need to reset for different testcase.
|
string DEFAULT = "1990";
|
||||||
string DEFAULT = "";
|
|
||||||
#else
|
|
||||||
static string DEFAULT = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Follow the HTTPS server if config HTTP API as the same of HTTP server.
|
// Follow the HTTPS server if config HTTP API as the same of HTTP server.
|
||||||
if (DEFAULT.empty()) {
|
if (get_http_api_listen() == get_http_stream_listen()) {
|
||||||
if (get_http_api_listen() == get_http_stream_listen()) {
|
DEFAULT = get_https_stream_listen();
|
||||||
DEFAULT = get_https_stream_listen();
|
|
||||||
} else {
|
|
||||||
DEFAULT = "1990";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* conf = get_https_api();
|
SrsConfDirective* conf = get_https_api();
|
||||||
|
|
|
@ -172,7 +172,7 @@ private:
|
||||||
public:
|
public:
|
||||||
SrsFastCoroutine(std::string n, ISrsCoroutineHandler* h);
|
SrsFastCoroutine(std::string n, ISrsCoroutineHandler* h);
|
||||||
SrsFastCoroutine(std::string n, ISrsCoroutineHandler* h, SrsContextId cid);
|
SrsFastCoroutine(std::string n, ISrsCoroutineHandler* h, SrsContextId cid);
|
||||||
~SrsFastCoroutine();
|
virtual ~SrsFastCoroutine();
|
||||||
public:
|
public:
|
||||||
void set_stack_size(int v);
|
void set_stack_size(int v);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -2047,7 +2047,7 @@ std::string SrsApmSpan::text_propagator()
|
||||||
// For text based propagation, for example, HTTP header "Traceparent: 00-bb8dedf16c53ab4b6ceb1f4ca6d985bb-29247096662468ab-01"
|
// For text based propagation, for example, HTTP header "Traceparent: 00-bb8dedf16c53ab4b6ceb1f4ca6d985bb-29247096662468ab-01"
|
||||||
// About the "%.2x", please see https://www.quora.com/What-does-2x-do-in-C-code for detail.
|
// About the "%.2x", please see https://www.quora.com/What-does-2x-do-in-C-code for detail.
|
||||||
int nn = snprintf(buf, sizeof(buf), "%.2x-%s-%s-%.2x", supportedVersion, ctx_->trace_id_.c_str(), ctx_->span_id_.c_str(), FlagsSampled);
|
int nn = snprintf(buf, sizeof(buf), "%.2x-%s-%s-%.2x", supportedVersion, ctx_->trace_id_.c_str(), ctx_->span_id_.c_str(), FlagsSampled);
|
||||||
if (nn > 0 && nn < sizeof(buf)) {
|
if (nn > 0 && nn < (int)sizeof(buf)) {
|
||||||
return string(buf, nn);
|
return string(buf, nn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,11 @@ std::string SrsCplxError::summary() {
|
||||||
if (_summary.empty()) {
|
if (_summary.empty()) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
|
|
||||||
|
ss << "code=" << code;
|
||||||
|
|
||||||
|
string code_str = srs_error_code_str(this);
|
||||||
|
if (!code_str.empty()) ss << "(" << code_str << ")";
|
||||||
|
|
||||||
SrsCplxError* next = this;
|
SrsCplxError* next = this;
|
||||||
while (next) {
|
while (next) {
|
||||||
ss << " : " << next->msg;
|
ss << " : " << next->msg;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,6 +28,7 @@ class SrsTsPayload;
|
||||||
class SrsTsMessage;
|
class SrsTsMessage;
|
||||||
class SrsTsPacket;
|
class SrsTsPacket;
|
||||||
class SrsTsContext;
|
class SrsTsContext;
|
||||||
|
class SrsPsPacket;
|
||||||
|
|
||||||
// Transport Stream packets are 188 bytes in length.
|
// Transport Stream packets are 188 bytes in length.
|
||||||
#define SRS_TS_PACKET_SIZE 188
|
#define SRS_TS_PACKET_SIZE 188
|
||||||
|
@ -90,14 +91,14 @@ enum SrsTsPidApply
|
||||||
{
|
{
|
||||||
SrsTsPidApplyReserved = 0, // TSPidTypeReserved, nothing parsed, used reserved.
|
SrsTsPidApplyReserved = 0, // TSPidTypeReserved, nothing parsed, used reserved.
|
||||||
|
|
||||||
SrsTsPidApplyPAT, // Program associtate table
|
SrsTsPidApplyPAT, // Program associtate table for TS.
|
||||||
SrsTsPidApplyPMT, // Program map table.
|
SrsTsPidApplyPMT, // Program map table for TS.
|
||||||
|
|
||||||
SrsTsPidApplyVideo, // for video
|
SrsTsPidApplyVideo, // for video
|
||||||
SrsTsPidApplyAudio, // vor audio
|
SrsTsPidApplyAudio, // vor audio
|
||||||
};
|
};
|
||||||
|
|
||||||
// Table 2-29 - Stream type assignments
|
// Table 2-29 - Stream type assignments, hls-mpeg-ts-iso13818-1.pdf, page 66
|
||||||
enum SrsTsStream
|
enum SrsTsStream
|
||||||
{
|
{
|
||||||
// ITU-T | ISO/IEC Reserved
|
// ITU-T | ISO/IEC Reserved
|
||||||
|
@ -215,9 +216,7 @@ enum SrsTsPESStreamId
|
||||||
class SrsTsMessage
|
class SrsTsMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// For decoder only,
|
// For decoder only, the ts message does not use them, for user to get the channel and packet.
|
||||||
// the ts messgae does not use them,
|
|
||||||
// for user to get the channel and packet.
|
|
||||||
SrsTsChannel* channel;
|
SrsTsChannel* channel;
|
||||||
SrsTsPacket* packet;
|
SrsTsPacket* packet;
|
||||||
public:
|
public:
|
||||||
|
@ -294,12 +293,10 @@ private:
|
||||||
// When PAT and PMT writen, the context is ready.
|
// When PAT and PMT writen, the context is ready.
|
||||||
// @see https://github.com/ossrs/srs/issues/834
|
// @see https://github.com/ossrs/srs/issues/834
|
||||||
bool ready;
|
bool ready;
|
||||||
// codec
|
|
||||||
private:
|
private:
|
||||||
std::map<int, SrsTsChannel*> pids;
|
std::map<int, SrsTsChannel*> pids;
|
||||||
bool pure_audio;
|
bool pure_audio;
|
||||||
int8_t sync_byte;
|
int8_t sync_byte;
|
||||||
// encoder
|
|
||||||
private:
|
private:
|
||||||
// when any codec changed, write the PAT/PMT.
|
// when any codec changed, write the PAT/PMT.
|
||||||
SrsVideoCodecId vcodec;
|
SrsVideoCodecId vcodec;
|
||||||
|
@ -309,37 +306,33 @@ public:
|
||||||
virtual ~SrsTsContext();
|
virtual ~SrsTsContext();
|
||||||
public:
|
public:
|
||||||
// Whether the hls stream is pure audio stream.
|
// Whether the hls stream is pure audio stream.
|
||||||
// TODO: FIXME: merge with muxer codec detect.
|
// TODO: FIXME: merge with muxer codec detect.
|
||||||
virtual bool is_pure_audio();
|
virtual bool is_pure_audio();
|
||||||
// When PMT table parsed, we know some info about stream.
|
// When PMT table parsed, we know some info about stream.
|
||||||
virtual void on_pmt_parsed();
|
virtual void on_pmt_parsed();
|
||||||
// Reset the context for a new ts segment start.
|
// Reset the context for a new ts segment start.
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
// codec
|
|
||||||
public:
|
public:
|
||||||
// Get the pid apply, the parsed pid.
|
// Get the pid apply, the parsed pid.
|
||||||
// @return the apply channel; NULL for invalid.
|
// @return the apply channel; NULL for invalid.
|
||||||
virtual SrsTsChannel* get(int pid);
|
virtual SrsTsChannel* get(int pid);
|
||||||
// Set the pid apply, the parsed pid.
|
// Set the pid apply, the parsed pid.
|
||||||
virtual void set(int pid, SrsTsPidApply apply_pid, SrsTsStream stream = SrsTsStreamReserved);
|
virtual void set(int pid, SrsTsPidApply apply_pid, SrsTsStream stream = SrsTsStreamReserved);
|
||||||
// decode methods
|
|
||||||
public:
|
public:
|
||||||
// The stream contains only one ts packet.
|
// Feed with ts packets, decode as ts message, callback handler if got one ts message.
|
||||||
// @param handler the ts message handler to process the msg.
|
// A ts video message can be decoded to NALUs by SrsRawH264Stream::annexb_demux.
|
||||||
// @remark we will consume all bytes in stream.
|
// A ts audio message can be decoded to RAW frame by SrsRawAacStream::adts_demux.
|
||||||
|
// @param handler The ts message handler to process the msg.
|
||||||
|
// @remark We will consume all bytes in stream.
|
||||||
virtual srs_error_t decode(SrsBuffer* stream, ISrsTsHandler* handler);
|
virtual srs_error_t decode(SrsBuffer* stream, ISrsTsHandler* handler);
|
||||||
// encode methods
|
|
||||||
public:
|
public:
|
||||||
// Write the PES packet, the video/audio stream.
|
// Encode ts video/audio messages to the PES packets, as PES stream.
|
||||||
// @param msg the video/audio msg to write to ts.
|
// @param msg The video/audio msg to write to ts.
|
||||||
// @param vc the video codec, write the PAT/PMT table when changed.
|
// A ts video message is a frame with one or more NALUs, generally encoded by SrsTsMessageCache.cache_video.
|
||||||
// @param ac the audio codec, write the PAT/PMT table when changed.
|
// A ts audio message is an audio packet, encoded by SrsTsMessageCache.cache_audio to ADTS for AAC.
|
||||||
|
// @param vc The video codec, write the PAT/PMT table when changed.
|
||||||
|
// @param ac The audio codec, write the PAT/PMT table when changed.
|
||||||
virtual srs_error_t encode(ISrsStreamWriter* writer, SrsTsMessage* msg, SrsVideoCodecId vc, SrsAudioCodecId ac);
|
virtual srs_error_t encode(ISrsStreamWriter* writer, SrsTsMessage* msg, SrsVideoCodecId vc, SrsAudioCodecId ac);
|
||||||
// drm methods
|
|
||||||
public:
|
|
||||||
// Set sync byte of ts segment.
|
|
||||||
// replace the standard ts sync byte to bravo sync byte.
|
|
||||||
virtual void set_sync_byte(int8_t sb);
|
|
||||||
private:
|
private:
|
||||||
virtual srs_error_t encode_pat_pmt(ISrsStreamWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as);
|
virtual srs_error_t encode_pat_pmt(ISrsStreamWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as);
|
||||||
virtual srs_error_t encode_pes(ISrsStreamWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio);
|
virtual srs_error_t encode_pes(ISrsStreamWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio);
|
||||||
|
@ -741,9 +734,8 @@ public:
|
||||||
virtual srs_error_t encode(SrsBuffer* stream) = 0;
|
virtual srs_error_t encode(SrsBuffer* stream) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The PES payload of ts packet.
|
// Common MPEG PES packet for both TS and PS.
|
||||||
// 2.4.3.6 PES packet, hls-mpeg-ts-iso13818-1.pdf, page 49
|
class SrsMpegPES
|
||||||
class SrsTsPayloadPES : public SrsTsPayload
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 3B
|
// 3B
|
||||||
|
@ -763,7 +755,7 @@ public:
|
||||||
// field. A value of 0 indicates that the PES packet length is neither specified nor bounded and is allowed only in
|
// field. A value of 0 indicates that the PES packet length is neither specified nor bounded and is allowed only in
|
||||||
// PES packets whose payload consists of bytes from a video elementary stream contained in Transport Stream packets.
|
// PES packets whose payload consists of bytes from a video elementary stream contained in Transport Stream packets.
|
||||||
uint16_t PES_packet_length; //16bits
|
uint16_t PES_packet_length; //16bits
|
||||||
|
|
||||||
// 1B
|
// 1B
|
||||||
// 2bits const '10'
|
// 2bits const '10'
|
||||||
int8_t const2bits; //2bits
|
int8_t const2bits; //2bits
|
||||||
|
@ -790,7 +782,7 @@ public:
|
||||||
// This is a 1-bit field. When set to '1' the contents of the associated PES packet payload is an original.
|
// This is a 1-bit field. When set to '1' the contents of the associated PES packet payload is an original.
|
||||||
// When set to '0' it indicates that the contents of the associated PES packet payload is a copy.
|
// When set to '0' it indicates that the contents of the associated PES packet payload is a copy.
|
||||||
int8_t original_or_copy; //1bit
|
int8_t original_or_copy; //1bit
|
||||||
|
|
||||||
// 1B
|
// 1B
|
||||||
// This is a 2-bit field. When the PTS_DTS_flags field is set to '10', the PTS fields shall be present in
|
// This is a 2-bit field. When the PTS_DTS_flags field is set to '10', the PTS fields shall be present in
|
||||||
// the PES packet header. When the PTS_DTS_flags field is set to '11', both the PTS fields and DTS fields shall be present
|
// the PES packet header. When the PTS_DTS_flags field is set to '11', both the PTS fields and DTS fields shall be present
|
||||||
|
@ -815,13 +807,13 @@ public:
|
||||||
// A 1-bit flag, which when set to '1' indicates that an extension field exists in this PES packet
|
// A 1-bit flag, which when set to '1' indicates that an extension field exists in this PES packet
|
||||||
// header. When set to '0' it indicates that this field is not present.
|
// header. When set to '0' it indicates that this field is not present.
|
||||||
int8_t PES_extension_flag; //1bit
|
int8_t PES_extension_flag; //1bit
|
||||||
|
|
||||||
// 1B
|
// 1B
|
||||||
// An 8-bit field specifying the total number of bytes occupied by the optional fields and any
|
// An 8-bit field specifying the total number of bytes occupied by the optional fields and any
|
||||||
// stuffing bytes contained in this PES packet header. The presence of optional fields is indicated in the byte that precedes
|
// stuffing bytes contained in this PES packet header. The presence of optional fields is indicated in the byte that precedes
|
||||||
// the PES_header_data_length field.
|
// the PES_header_data_length field.
|
||||||
uint8_t PES_header_data_length; //8bits
|
uint8_t PES_header_data_length; //8bits
|
||||||
|
|
||||||
// 5B
|
// 5B
|
||||||
// Presentation times shall be related to decoding times as follows: The PTS is a 33-bit
|
// Presentation times shall be related to decoding times as follows: The PTS is a 33-bit
|
||||||
// number coded in three separate fields. It indicates the time of presentation, tp n (k), in the system target decoder of a
|
// number coded in three separate fields. It indicates the time of presentation, tp n (k), in the system target decoder of a
|
||||||
|
@ -839,7 +831,7 @@ public:
|
||||||
// 15bits PTS [14..0]
|
// 15bits PTS [14..0]
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
int64_t pts; // 33bits
|
int64_t pts; // 33bits
|
||||||
|
|
||||||
// 5B
|
// 5B
|
||||||
// The DTS is a 33-bit number coded in three separate fields. It indicates the decoding time,
|
// The DTS is a 33-bit number coded in three separate fields. It indicates the decoding time,
|
||||||
// td n (j), in the system target decoder of an access unit j of elementary stream n. The value of DTS is specified in units of
|
// td n (j), in the system target decoder of an access unit j of elementary stream n. The value of DTS is specified in units of
|
||||||
|
@ -855,7 +847,7 @@ public:
|
||||||
// 15bits DTS [14..0]
|
// 15bits DTS [14..0]
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
int64_t dts; // 33bits
|
int64_t dts; // 33bits
|
||||||
|
|
||||||
// 6B
|
// 6B
|
||||||
// The elementary stream clock reference is a 42-bit field coded in two parts. The first
|
// The elementary stream clock reference is a 42-bit field coded in two parts. The first
|
||||||
// part, ESCR_base, is a 33-bit field whose value is given by ESCR_base(i), as given in equation 2-14. The second part,
|
// part, ESCR_base, is a 33-bit field whose value is given by ESCR_base(i), as given in equation 2-14. The second part,
|
||||||
|
@ -873,7 +865,7 @@ public:
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
int64_t ESCR_base; //33bits
|
int64_t ESCR_base; //33bits
|
||||||
int16_t ESCR_extension; //9bits
|
int16_t ESCR_extension; //9bits
|
||||||
|
|
||||||
// 3B
|
// 3B
|
||||||
// The ES_rate field is a 22-bit unsigned integer specifying the rate at which the
|
// The ES_rate field is a 22-bit unsigned integer specifying the rate at which the
|
||||||
// system target decoder receives bytes of the PES packet in the case of a PES stream. The ES_rate is valid in the PES
|
// system target decoder receives bytes of the PES packet in the case of a PES stream. The ES_rate is valid in the PES
|
||||||
|
@ -885,24 +877,24 @@ public:
|
||||||
// 22bits ES_rate
|
// 22bits ES_rate
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
int32_t ES_rate; //22bits
|
int32_t ES_rate; //22bits
|
||||||
|
|
||||||
// 1B
|
// 1B
|
||||||
// A 3-bit field that indicates which trick mode is applied to the associated video stream. In cases of
|
// A 3-bit field that indicates which trick mode is applied to the associated video stream. In cases of
|
||||||
// other types of elementary streams, the meanings of this field and those defined by the following five bits are undefined.
|
// other types of elementary streams, the meanings of this field and those defined by the following five bits are undefined.
|
||||||
// For the definition of trick_mode status, refer to the trick mode section of 2.4.2.3.
|
// For the definition of trick_mode status, refer to the trick mode section of 2.4.2.3.
|
||||||
int8_t trick_mode_control; //3bits
|
int8_t trick_mode_control; //3bits
|
||||||
int8_t trick_mode_value; //5bits
|
int8_t trick_mode_value; //5bits
|
||||||
|
|
||||||
// 1B
|
// 1B
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
// This 7-bit field contains private data relating to copyright information.
|
// This 7-bit field contains private data relating to copyright information.
|
||||||
int8_t additional_copy_info; //7bits
|
int8_t additional_copy_info; //7bits
|
||||||
|
|
||||||
// 2B
|
// 2B
|
||||||
// The previous_PES_packet_CRC is a 16-bit field that contains the CRC value that yields
|
// The previous_PES_packet_CRC is a 16-bit field that contains the CRC value that yields
|
||||||
// a zero output of the 16 registers in the decoder similar to the one defined in Annex A,
|
// a zero output of the 16 registers in the decoder similar to the one defined in Annex A,
|
||||||
int16_t previous_PES_packet_CRC; //16bits
|
int16_t previous_PES_packet_CRC; //16bits
|
||||||
|
|
||||||
// 1B
|
// 1B
|
||||||
// A 1-bit flag which when set to '1' indicates that the PES packet header contains private data.
|
// A 1-bit flag which when set to '1' indicates that the PES packet header contains private data.
|
||||||
// When set to a value of '0' it indicates that private data is not present in the PES header.
|
// When set to a value of '0' it indicates that private data is not present in the PES header.
|
||||||
|
@ -926,15 +918,15 @@ public:
|
||||||
// field and associated fields. When set to a value of '0' this indicates that the PES_extension_field_length field and any
|
// field and associated fields. When set to a value of '0' this indicates that the PES_extension_field_length field and any
|
||||||
// associated fields are not present.
|
// associated fields are not present.
|
||||||
int8_t PES_extension_flag_2; //1bit
|
int8_t PES_extension_flag_2; //1bit
|
||||||
|
|
||||||
// 16B
|
// 16B
|
||||||
// This is a 16-byte field which contains private data. This data, combined with the fields before and
|
// This is a 16-byte field which contains private data. This data, combined with the fields before and
|
||||||
// after, shall not emulate the packet_start_code_prefix (0x000001).
|
// after, shall not emulate the packet_start_code_prefix (0x000001).
|
||||||
std::vector<char> PES_private_data; //128bits
|
std::vector<char> PES_private_data; //128bits
|
||||||
|
|
||||||
// (1+x)B
|
// (1+x)B
|
||||||
std::vector<char> pack_field; //[pack_field_length] bytes
|
std::vector<char> pack_field; //[pack_field_length] bytes
|
||||||
|
|
||||||
// 2B
|
// 2B
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
// The program_packet_sequence_counter field is a 7-bit field. It is an optional
|
// The program_packet_sequence_counter field is a 7-bit field. It is an optional
|
||||||
|
@ -952,7 +944,7 @@ public:
|
||||||
// This 6-bit field specifies the number of stuffing bytes used in the original ITU-T
|
// This 6-bit field specifies the number of stuffing bytes used in the original ITU-T
|
||||||
// Rec. H.222.0 | ISO/IEC 13818-1 PES packet header or in the original ISO/IEC 11172-1 packet header.
|
// Rec. H.222.0 | ISO/IEC 13818-1 PES packet header or in the original ISO/IEC 11172-1 packet header.
|
||||||
int8_t original_stuff_length; //6bits
|
int8_t original_stuff_length; //6bits
|
||||||
|
|
||||||
// 2B
|
// 2B
|
||||||
// 2bits const '01'
|
// 2bits const '01'
|
||||||
// The P-STD_buffer_scale is a 1-bit field, the meaning of which is only defined if this PES packet
|
// The P-STD_buffer_scale is a 1-bit field, the meaning of which is only defined if this PES packet
|
||||||
|
@ -966,17 +958,17 @@ public:
|
||||||
// P-STD_buffer_scale has the value '0', then the P-STD_buffer_size measures the buffer size in units of 128 bytes. If
|
// P-STD_buffer_scale has the value '0', then the P-STD_buffer_size measures the buffer size in units of 128 bytes. If
|
||||||
// P-STD_buffer_scale has the value '1', then the P-STD_buffer_size measures the buffer size in units of 1024 bytes.
|
// P-STD_buffer_scale has the value '1', then the P-STD_buffer_size measures the buffer size in units of 1024 bytes.
|
||||||
int16_t P_STD_buffer_size; //13bits
|
int16_t P_STD_buffer_size; //13bits
|
||||||
|
|
||||||
// (1+x)B
|
// (1+x)B
|
||||||
// 1bit const '1'
|
// 1bit const '1'
|
||||||
std::vector<char> PES_extension_field; //[PES_extension_field_length] bytes
|
std::vector<char> PES_extension_field; //[PES_extension_field_length] bytes
|
||||||
|
|
||||||
// NB
|
// NB
|
||||||
// This is a fixed 8-bit value equal to '1111 1111' that can be inserted by the encoder, for example to meet
|
// This is a fixed 8-bit value equal to '1111 1111' that can be inserted by the encoder, for example to meet
|
||||||
// the requirements of the channel. It is discarded by the decoder. No more than 32 stuffing bytes shall be present in one
|
// the requirements of the channel. It is discarded by the decoder. No more than 32 stuffing bytes shall be present in one
|
||||||
// PES packet header.
|
// PES packet header.
|
||||||
int nb_stuffings;
|
int nb_stuffings;
|
||||||
|
|
||||||
// NB
|
// NB
|
||||||
// PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
|
// PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
|
||||||
// indicated by the packet's stream_id or PID. When the elementary stream data conforms to ITU-T
|
// indicated by the packet's stream_id or PID. When the elementary stream data conforms to ITU-T
|
||||||
|
@ -989,10 +981,33 @@ public:
|
||||||
// In the case of a private_stream_1, private_stream_2, ECM_stream, or EMM_stream, the contents of the
|
// In the case of a private_stream_1, private_stream_2, ECM_stream, or EMM_stream, the contents of the
|
||||||
// PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future.
|
// PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future.
|
||||||
int nb_bytes;
|
int nb_bytes;
|
||||||
|
|
||||||
// NB
|
// NB
|
||||||
// This is a fixed 8-bit value equal to '1111 1111'. It is discarded by the decoder.
|
// This is a fixed 8-bit value equal to '1111 1111'. It is discarded by the decoder.
|
||||||
int nb_paddings;
|
int nb_paddings;
|
||||||
|
public:
|
||||||
|
// Whether contains payload to dump to message.
|
||||||
|
bool has_payload_;
|
||||||
|
int nb_payload_;
|
||||||
|
public:
|
||||||
|
SrsMpegPES();
|
||||||
|
virtual ~SrsMpegPES();
|
||||||
|
public:
|
||||||
|
virtual srs_error_t decode(SrsBuffer* stream);
|
||||||
|
public:
|
||||||
|
virtual int size();
|
||||||
|
virtual srs_error_t encode(SrsBuffer* stream);
|
||||||
|
private:
|
||||||
|
virtual srs_error_t decode_33bits_dts_pts(SrsBuffer* stream, int64_t* pv);
|
||||||
|
virtual srs_error_t encode_33bits_dts_pts(SrsBuffer* stream, uint8_t fb, int64_t v);
|
||||||
|
};
|
||||||
|
|
||||||
|
// The PES payload of ts packet.
|
||||||
|
// 2.4.3.6 PES packet, hls-mpeg-ts-iso13818-1.pdf, page 49
|
||||||
|
class SrsTsPayloadPES : public SrsTsPayload
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SrsMpegPES pes;
|
||||||
public:
|
public:
|
||||||
SrsTsPayloadPES(SrsTsPacket* p);
|
SrsTsPayloadPES(SrsTsPacket* p);
|
||||||
virtual ~SrsTsPayloadPES();
|
virtual ~SrsTsPayloadPES();
|
||||||
|
@ -1001,9 +1016,6 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int size();
|
virtual int size();
|
||||||
virtual srs_error_t encode(SrsBuffer* stream);
|
virtual srs_error_t encode(SrsBuffer* stream);
|
||||||
private:
|
|
||||||
virtual srs_error_t decode_33bits_dts_pts(SrsBuffer* stream, int64_t* pv);
|
|
||||||
virtual srs_error_t encode_33bits_dts_pts(SrsBuffer* stream, uint8_t fb, int64_t v);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// The PSI payload of ts packet.
|
// The PSI payload of ts packet.
|
||||||
|
|
|
@ -765,7 +765,7 @@ VOID TEST(KernelRTCTest, NACKEncode)
|
||||||
vector<uint16_t> before = rtcp_nack_encode.get_lost_sns();
|
vector<uint16_t> before = rtcp_nack_encode.get_lost_sns();
|
||||||
vector<uint16_t> after = rtcp_nack_decode.get_lost_sns();
|
vector<uint16_t> after = rtcp_nack_decode.get_lost_sns();
|
||||||
EXPECT_TRUE(before.size() == after.size());
|
EXPECT_TRUE(before.size() == after.size());
|
||||||
for(int i = 0; i < before.size() && i < after.size(); ++i) {
|
for(int i = 0; i < (int)before.size() && i < (int)after.size(); ++i) {
|
||||||
EXPECT_TRUE(before.at(i) == after.at(i));
|
EXPECT_TRUE(before.at(i) == after.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -932,11 +932,11 @@ VOID TEST(KernelRTCTest, Ntp)
|
||||||
// Cover systime to ntp
|
// Cover systime to ntp
|
||||||
SrsNtp ntp = SrsNtp::from_time_ms(now_ms);
|
SrsNtp ntp = SrsNtp::from_time_ms(now_ms);
|
||||||
|
|
||||||
ASSERT_EQ(ntp.system_ms_, now_ms);
|
ASSERT_EQ((srs_utime_t)ntp.system_ms_, now_ms);
|
||||||
|
|
||||||
// Cover ntp to systime
|
// Cover ntp to systime
|
||||||
SrsNtp ntp1 = SrsNtp::to_time_ms(ntp.ntp_);
|
SrsNtp ntp1 = SrsNtp::to_time_ms(ntp.ntp_);
|
||||||
ASSERT_EQ(ntp1.system_ms_, now_ms);
|
ASSERT_EQ((srs_utime_t)ntp1.system_ms_, now_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,10 +945,10 @@ VOID TEST(KernelRTCTest, Ntp)
|
||||||
srs_utime_t now_ms = srs_get_system_time() / 1000;
|
srs_utime_t now_ms = srs_get_system_time() / 1000;
|
||||||
SrsNtp ntp = SrsNtp::from_time_ms(now_ms);
|
SrsNtp ntp = SrsNtp::from_time_ms(now_ms);
|
||||||
|
|
||||||
ASSERT_EQ(ntp.system_ms_, now_ms);
|
ASSERT_EQ((srs_utime_t)ntp.system_ms_, now_ms);
|
||||||
|
|
||||||
SrsNtp ntp1 = SrsNtp::to_time_ms(ntp.ntp_);
|
SrsNtp ntp1 = SrsNtp::to_time_ms(ntp.ntp_);
|
||||||
ASSERT_EQ(ntp1.system_ms_, now_ms);
|
ASSERT_EQ((srs_utime_t)ntp1.system_ms_, now_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,46 +1279,46 @@ VOID TEST(KernelRTCTest, JitterTimestamp)
|
||||||
SrsRtcTsJitter jitter(1000);
|
SrsRtcTsJitter jitter(1000);
|
||||||
|
|
||||||
// Starts from the base.
|
// Starts from the base.
|
||||||
EXPECT_EQ(1000, jitter.correct(0));
|
EXPECT_EQ((uint32_t)1000, jitter.correct(0));
|
||||||
|
|
||||||
// Start from here.
|
// Start from here.
|
||||||
EXPECT_EQ(1010, jitter.correct(10));
|
EXPECT_EQ((uint32_t)1010, jitter.correct(10));
|
||||||
EXPECT_EQ(1010, jitter.correct(10));
|
EXPECT_EQ((uint32_t)1010, jitter.correct(10));
|
||||||
EXPECT_EQ(1020, jitter.correct(20));
|
EXPECT_EQ((uint32_t)1020, jitter.correct(20));
|
||||||
|
|
||||||
// Reset the base for jitter detected.
|
// Reset the base for jitter detected.
|
||||||
EXPECT_EQ(1020, jitter.correct(20 + 90*3*1000 + 1));
|
EXPECT_EQ((uint32_t)1020, jitter.correct(20 + 90*3*1000 + 1));
|
||||||
EXPECT_EQ(1019, jitter.correct(20 + 90*3*1000));
|
EXPECT_EQ((uint32_t)1019, jitter.correct(20 + 90*3*1000));
|
||||||
EXPECT_EQ(1021, jitter.correct(20 + 90*3*1000 + 2));
|
EXPECT_EQ((uint32_t)1021, jitter.correct(20 + 90*3*1000 + 2));
|
||||||
EXPECT_EQ(1019, jitter.correct(20 + 90*3*1000));
|
EXPECT_EQ((uint32_t)1019, jitter.correct(20 + 90*3*1000));
|
||||||
EXPECT_EQ(1020, jitter.correct(20 + 90*3*1000 + 1));
|
EXPECT_EQ((uint32_t)1020, jitter.correct(20 + 90*3*1000 + 1));
|
||||||
|
|
||||||
// Rollback the timestamp.
|
// Rollback the timestamp.
|
||||||
EXPECT_EQ(1020, jitter.correct(20));
|
EXPECT_EQ((uint32_t)1020, jitter.correct(20));
|
||||||
EXPECT_EQ(1021, jitter.correct(20 + 1));
|
EXPECT_EQ((uint32_t)1021, jitter.correct(20 + 1));
|
||||||
EXPECT_EQ(1021, jitter.correct(21));
|
EXPECT_EQ((uint32_t)1021, jitter.correct(21));
|
||||||
|
|
||||||
// Reset for jitter again.
|
// Reset for jitter again.
|
||||||
EXPECT_EQ(1021, jitter.correct(21 + 90*3*1000 + 1));
|
EXPECT_EQ((uint32_t)1021, jitter.correct(21 + 90*3*1000 + 1));
|
||||||
EXPECT_EQ(1021, jitter.correct(21));
|
EXPECT_EQ((uint32_t)1021, jitter.correct(21));
|
||||||
|
|
||||||
// No jitter at edge.
|
// No jitter at edge.
|
||||||
EXPECT_EQ(1021 + 90*3*1000, jitter.correct(21 + 90*3*1000));
|
EXPECT_EQ((uint32_t)(1021 + 90*3*1000), jitter.correct(21 + 90*3*1000));
|
||||||
EXPECT_EQ(1021 + 90*3*1000 + 1, jitter.correct(21 + 90*3*1000 + 1));
|
EXPECT_EQ((uint32_t)(1021 + 90*3*1000 + 1), jitter.correct(21 + 90*3*1000 + 1));
|
||||||
EXPECT_EQ(1021 + 1, jitter.correct(21 + 1));
|
EXPECT_EQ((uint32_t)(1021 + 1), jitter.correct(21 + 1));
|
||||||
|
|
||||||
// Also safety to decrease the value.
|
// Also safety to decrease the value.
|
||||||
EXPECT_EQ(1021, jitter.correct(21));
|
EXPECT_EQ((uint32_t)1021, jitter.correct(21));
|
||||||
EXPECT_EQ(1010, jitter.correct(10));
|
EXPECT_EQ((uint32_t)1010, jitter.correct(10));
|
||||||
|
|
||||||
// Try to reset to 0 base.
|
// Try to reset to 0 base.
|
||||||
EXPECT_EQ(1010, jitter.correct(10 + 90*3*1000 + 1010));
|
EXPECT_EQ((uint32_t)1010, jitter.correct(10 + 90*3*1000 + 1010));
|
||||||
EXPECT_EQ(0, jitter.correct(10 + 90*3*1000));
|
EXPECT_EQ((uint32_t)0, jitter.correct(10 + 90*3*1000));
|
||||||
EXPECT_EQ(0, jitter.correct(0));
|
EXPECT_EQ((uint32_t)0, jitter.correct(0));
|
||||||
|
|
||||||
// Also safety to start from zero.
|
// Also safety to start from zero.
|
||||||
EXPECT_EQ(10, jitter.correct(10));
|
EXPECT_EQ((uint32_t)10, jitter.correct(10));
|
||||||
EXPECT_EQ(11, jitter.correct(11));
|
EXPECT_EQ((uint32_t)11, jitter.correct(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID TEST(KernelRTCTest, JitterSequence)
|
VOID TEST(KernelRTCTest, JitterSequence)
|
||||||
|
@ -1326,45 +1326,45 @@ VOID TEST(KernelRTCTest, JitterSequence)
|
||||||
SrsRtcSeqJitter jitter(100);
|
SrsRtcSeqJitter jitter(100);
|
||||||
|
|
||||||
// Starts from the base.
|
// Starts from the base.
|
||||||
EXPECT_EQ(100, jitter.correct(0));
|
EXPECT_EQ((uint32_t)100, jitter.correct(0));
|
||||||
|
|
||||||
// Normal without jitter.
|
// Normal without jitter.
|
||||||
EXPECT_EQ(101, jitter.correct(1));
|
EXPECT_EQ((uint32_t)101, jitter.correct(1));
|
||||||
EXPECT_EQ(102, jitter.correct(2));
|
EXPECT_EQ((uint32_t)102, jitter.correct(2));
|
||||||
EXPECT_EQ(101, jitter.correct(1));
|
EXPECT_EQ((uint32_t)101, jitter.correct(1));
|
||||||
EXPECT_EQ(103, jitter.correct(3));
|
EXPECT_EQ((uint32_t)103, jitter.correct(3));
|
||||||
EXPECT_EQ(110, jitter.correct(10));
|
EXPECT_EQ((uint32_t)110, jitter.correct(10));
|
||||||
|
|
||||||
// Reset the base for jitter detected.
|
// Reset the base for jitter detected.
|
||||||
EXPECT_EQ(110, jitter.correct(10 + 128 + 1));
|
EXPECT_EQ((uint32_t)110, jitter.correct(10 + 128 + 1));
|
||||||
EXPECT_EQ(109, jitter.correct(10 + 128));
|
EXPECT_EQ((uint32_t)109, jitter.correct(10 + 128));
|
||||||
EXPECT_EQ(110, jitter.correct(10 + 128 + 1));
|
EXPECT_EQ((uint32_t)110, jitter.correct(10 + 128 + 1));
|
||||||
|
|
||||||
// Rollback the timestamp.
|
// Rollback the timestamp.
|
||||||
EXPECT_EQ(110, jitter.correct(10));
|
EXPECT_EQ((uint32_t)110, jitter.correct(10));
|
||||||
EXPECT_EQ(111, jitter.correct(10 + 1));
|
EXPECT_EQ((uint32_t)111, jitter.correct(10 + 1));
|
||||||
EXPECT_EQ(111, jitter.correct(11));
|
EXPECT_EQ((uint32_t)111, jitter.correct(11));
|
||||||
|
|
||||||
// Reset for jitter again.
|
// Reset for jitter again.
|
||||||
EXPECT_EQ(111, jitter.correct(11 + 128 + 1));
|
EXPECT_EQ((uint32_t)111, jitter.correct(11 + 128 + 1));
|
||||||
EXPECT_EQ(111, jitter.correct(11));
|
EXPECT_EQ((uint32_t)111, jitter.correct(11));
|
||||||
|
|
||||||
// No jitter at edge.
|
// No jitter at edge.
|
||||||
EXPECT_EQ(111 + 128, jitter.correct(11 + 128));
|
EXPECT_EQ((uint32_t)(111 + 128), jitter.correct(11 + 128));
|
||||||
EXPECT_EQ(111 + 128 + 1, jitter.correct(11 + 128 + 1));
|
EXPECT_EQ((uint32_t)(111 + 128 + 1), jitter.correct(11 + 128 + 1));
|
||||||
EXPECT_EQ(111 + 1, jitter.correct(11 + 1));
|
EXPECT_EQ((uint32_t)(111 + 1), jitter.correct(11 + 1));
|
||||||
|
|
||||||
// Also safety to decrease the value.
|
// Also safety to decrease the value.
|
||||||
EXPECT_EQ(111, jitter.correct(11));
|
EXPECT_EQ((uint32_t)111, jitter.correct(11));
|
||||||
EXPECT_EQ(110, jitter.correct(10));
|
EXPECT_EQ((uint32_t)110, jitter.correct(10));
|
||||||
|
|
||||||
// Try to reset to 0 base.
|
// Try to reset to 0 base.
|
||||||
EXPECT_EQ(110, jitter.correct(10 + 128 + 110));
|
EXPECT_EQ((uint32_t)110, jitter.correct(10 + 128 + 110));
|
||||||
EXPECT_EQ(0, jitter.correct(10 + 128));
|
EXPECT_EQ((uint32_t)0, jitter.correct(10 + 128));
|
||||||
EXPECT_EQ(0, jitter.correct(0));
|
EXPECT_EQ((uint32_t)0, jitter.correct(0));
|
||||||
|
|
||||||
// Also safety to start from zero.
|
// Also safety to start from zero.
|
||||||
EXPECT_EQ(10, jitter.correct(10));
|
EXPECT_EQ((uint32_t)10, jitter.correct(10));
|
||||||
EXPECT_EQ(11, jitter.correct(11));
|
EXPECT_EQ((uint32_t)11, jitter.correct(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,22 +275,22 @@ VOID TEST(ServiceStSRTTest, ReadWrite)
|
||||||
// Client send msg to server.
|
// Client send msg to server.
|
||||||
ssize_t nb_write = 0;
|
ssize_t nb_write = 0;
|
||||||
HELPER_EXPECT_SUCCESS(srt_client_socket->sendmsg((char*)content.data(), content.size(), &nb_write));
|
HELPER_EXPECT_SUCCESS(srt_client_socket->sendmsg((char*)content.data(), content.size(), &nb_write));
|
||||||
EXPECT_EQ(nb_write, content.size());
|
EXPECT_EQ((size_t)nb_write, content.size());
|
||||||
|
|
||||||
// Server recv msg from client
|
// Server recv msg from client
|
||||||
char buf[1500];
|
char buf[1500];
|
||||||
ssize_t nb_read = 0;
|
ssize_t nb_read = 0;
|
||||||
HELPER_EXPECT_SUCCESS(srt_server_accepted_socket->recvmsg(buf, sizeof(buf), &nb_read));
|
HELPER_EXPECT_SUCCESS(srt_server_accepted_socket->recvmsg(buf, sizeof(buf), &nb_read));
|
||||||
EXPECT_EQ(nb_read, content.size());
|
EXPECT_EQ((size_t)nb_read, content.size());
|
||||||
EXPECT_EQ(std::string(buf, nb_read), content);
|
EXPECT_EQ(std::string(buf, nb_read), content);
|
||||||
|
|
||||||
// Server echo msg back to client.
|
// Server echo msg back to client.
|
||||||
HELPER_EXPECT_SUCCESS(srt_server_accepted_socket->sendmsg(buf, nb_read, &nb_write));
|
HELPER_EXPECT_SUCCESS(srt_server_accepted_socket->sendmsg(buf, nb_read, &nb_write));
|
||||||
EXPECT_EQ(nb_write, content.size());
|
EXPECT_EQ((size_t)nb_write, content.size());
|
||||||
|
|
||||||
// Client recv echo msg from server.
|
// Client recv echo msg from server.
|
||||||
HELPER_EXPECT_SUCCESS(srt_client_socket->recvmsg(buf, sizeof(buf), &nb_read));
|
HELPER_EXPECT_SUCCESS(srt_client_socket->recvmsg(buf, sizeof(buf), &nb_read));
|
||||||
EXPECT_EQ(nb_read, content.size());
|
EXPECT_EQ((size_t)nb_read, content.size());
|
||||||
EXPECT_EQ(std::string(buf, nb_read), content);
|
EXPECT_EQ(std::string(buf, nb_read), content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue