mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Support FFmpeg timecode, fix AMF0 parsing failed. v5.0.179 v6.0.77 (#3804)
Please see https://github.com/ossrs/srs/issues/3803 for detail: 1. When using FFmpeg with the `-map 0` option, there may be a 4-byte timecode in the AMF0 Data. 2. SRS should be able to handle this packet without causing a parsing error, as it's generally expected to be an AMF0 string, not a 4-byte timecode. 3. Disregard the timecode since SRS doesn't utilize it. See [Error submitting a packet to the muxer: Broken pipe, Error muxing a packet](https://trac.ffmpeg.org/ticket/10565) --------- Co-authored-by: john <hondaxiao@tencent.com>
This commit is contained in:
parent
4362df743b
commit
6a4ace900d
8 changed files with 78 additions and 68 deletions
|
@ -24,6 +24,7 @@ using namespace std;
|
|||
#include <srs_protocol_rtmp_stack.hpp>
|
||||
#include <srs_protocol_io.hpp>
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
|
@ -962,3 +963,63 @@ utsname* srs_get_system_uname_info()
|
|||
return system_info;
|
||||
}
|
||||
#endif
|
||||
|
||||
string srs_string_dumps_hex(const std::string& str)
|
||||
{
|
||||
return srs_string_dumps_hex(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
string srs_string_dumps_hex(const char* str, int length)
|
||||
{
|
||||
return srs_string_dumps_hex(str, length, INT_MAX);
|
||||
}
|
||||
|
||||
string srs_string_dumps_hex(const char* str, int length, int limit)
|
||||
{
|
||||
return srs_string_dumps_hex(str, length, limit, ' ', 128, '\n');
|
||||
}
|
||||
|
||||
string srs_string_dumps_hex(const char* str, int length, int limit, char seperator, int line_limit, char newline)
|
||||
{
|
||||
// 1 byte trailing '\0'.
|
||||
const int LIMIT = 1024*16 + 1;
|
||||
static char buf[LIMIT];
|
||||
|
||||
int len = 0;
|
||||
for (int i = 0; i < length && i < limit && len < LIMIT; ++i) {
|
||||
int nb = snprintf(buf + len, LIMIT - len, "%02x", (uint8_t)str[i]);
|
||||
if (nb <= 0 || nb >= LIMIT - len) {
|
||||
break;
|
||||
}
|
||||
len += nb;
|
||||
|
||||
// Only append seperator and newline when not last byte.
|
||||
if (i < length - 1 && i < limit - 1 && len < LIMIT) {
|
||||
if (seperator) {
|
||||
buf[len++] = seperator;
|
||||
}
|
||||
|
||||
if (newline && line_limit && i > 0 && ((i + 1) % line_limit) == 0) {
|
||||
buf[len++] = newline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty string.
|
||||
if (len <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// If overflow, cut the trailing newline.
|
||||
if (newline && len >= LIMIT - 2 && buf[len - 1] == newline) {
|
||||
len--;
|
||||
}
|
||||
|
||||
// If overflow, cut the trailing seperator.
|
||||
if (seperator && len >= LIMIT - 3 && buf[len - 1] == seperator) {
|
||||
len--;
|
||||
}
|
||||
|
||||
return string(buf, len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue