mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #155, fix all warnings for mac.
This commit is contained in:
parent
51967afb52
commit
a15ce1147f
12 changed files with 148 additions and 148 deletions
|
@ -38,6 +38,9 @@ gcc srs_flv_injecter.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_flv_i
|
||||||
#define ERROR_INJECTED 10000
|
#define ERROR_INJECTED 10000
|
||||||
|
|
||||||
int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, srs_flv_t* poc);
|
int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, srs_flv_t* poc);
|
||||||
|
int build_keyframes(srs_flv_t ic, srs_amf0_t *pname, srs_amf0_t* pdata, srs_amf0_t* pfilepositions, int64_t* pmetadata_end_offset);
|
||||||
|
int do_inject_flv(srs_flv_t ic, srs_flv_t oc, srs_amf0_t amf0_name, srs_amf0_t amf0_data, srs_amf0_t filepositions, int64_t metadata_end_offset);
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
@ -122,6 +122,8 @@ int parse_bytes(char* data, int size, char* hbuf, int hsize, char* tbuf, int tsi
|
||||||
if (size > print_size * 2) {
|
if (size > print_size * 2) {
|
||||||
digit_to_char(data + size - print_size, size, tbuf, tsize - 1);
|
digit_to_char(data + size - print_size, size, tbuf, tsize - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_flv(srs_flv_t flv)
|
int parse_flv(srs_flv_t flv)
|
||||||
|
|
|
@ -146,11 +146,11 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
srs_human_trace("publish stream success");
|
srs_human_trace("publish stream success");
|
||||||
|
|
||||||
u_int32_t dts = 0;
|
int dts = 0;
|
||||||
u_int32_t pts = 0;
|
int pts = 0;
|
||||||
// @remark, the dts and pts if read from device, for instance, the encode lib,
|
// @remark, the dts and pts if read from device, for instance, the encode lib,
|
||||||
// so we assume the fps is 25, and each h264 frame is 1000ms/25fps=40ms/f.
|
// so we assume the fps is 25, and each h264 frame is 1000ms/25fps=40ms/f.
|
||||||
u_int32_t fps = 25;
|
int fps = 25;
|
||||||
// @remark, to decode the file.
|
// @remark, to decode the file.
|
||||||
char* p = h264_raw;
|
char* p = h264_raw;
|
||||||
for (;p < h264_raw + file_size;) {
|
for (;p < h264_raw + file_size;) {
|
||||||
|
@ -158,9 +158,7 @@ int main(int argc, char** argv)
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int nb_start_code = 0;
|
int nb_start_code = 0;
|
||||||
if (read_h264_frame(h264_raw, file_size, &p, &nb_start_code, fps,
|
if (read_h264_frame(h264_raw, (int)file_size, &p, &nb_start_code, fps, &data, &size, &dts, &pts) < 0) {
|
||||||
&data, &size, &dts, &pts) < 0
|
|
||||||
) {
|
|
||||||
srs_human_trace("read a frame from file buffer failed.");
|
srs_human_trace("read a frame from file buffer failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,6 @@ private:
|
||||||
|
|
||||||
SrsHds::SrsHds(SrsSource *s)
|
SrsHds::SrsHds(SrsSource *s)
|
||||||
: currentSegment(NULL)
|
: currentSegment(NULL)
|
||||||
, source(s)
|
|
||||||
, fragment_index(1)
|
, fragment_index(1)
|
||||||
, video_sh(NULL)
|
, video_sh(NULL)
|
||||||
, audio_sh(NULL)
|
, audio_sh(NULL)
|
||||||
|
|
|
@ -55,7 +55,6 @@ private:
|
||||||
private:
|
private:
|
||||||
std::list<SrsHdsFragment *> fragments;
|
std::list<SrsHdsFragment *> fragments;
|
||||||
SrsHdsFragment *currentSegment;
|
SrsHdsFragment *currentSegment;
|
||||||
SrsSource *source;
|
|
||||||
int fragment_index;
|
int fragment_index;
|
||||||
SrsSharedPtrMessage *video_sh;
|
SrsSharedPtrMessage *video_sh;
|
||||||
SrsSharedPtrMessage *audio_sh;
|
SrsSharedPtrMessage *audio_sh;
|
||||||
|
|
|
@ -932,8 +932,8 @@ int SrsHttpResponseReader::read_chunked(std::string& data)
|
||||||
srs_assert(length >= 3);
|
srs_assert(length >= 3);
|
||||||
|
|
||||||
// it's ok to set the pos and pos+1 to NULL.
|
// it's ok to set the pos and pos+1 to NULL.
|
||||||
at[length - 1] = NULL;
|
at[length - 1] = 0;
|
||||||
at[length - 2] = NULL;
|
at[length - 2] = 0;
|
||||||
|
|
||||||
// size is the bytes size, excludes the chunk header and end CRLF.
|
// size is the bytes size, excludes the chunk header and end CRLF.
|
||||||
int ilength = ::strtol(at, NULL, 16);
|
int ilength = ::strtol(at, NULL, 16);
|
||||||
|
|
|
@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_app_st.hpp>
|
#include <srs_app_st.hpp>
|
||||||
#include <srs_app_thread.hpp>
|
#include <srs_app_thread.hpp>
|
||||||
|
|
||||||
class sockaddr_in;
|
struct sockaddr_in;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the udp packet handler.
|
* the udp packet handler.
|
||||||
|
|
|
@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifdef SRS_AUTO_STREAM_CASTER
|
#ifdef SRS_AUTO_STREAM_CASTER
|
||||||
|
|
||||||
class sockaddr_in;
|
struct sockaddr_in;
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class SrsRequest;
|
||||||
class SrsRawH264Stream;
|
class SrsRawH264Stream;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
class SrsRawAacStream;
|
class SrsRawAacStream;
|
||||||
class SrsRawAacStreamCodec;
|
struct SrsRawAacStreamCodec;
|
||||||
class SrsPithyPrint;
|
class SrsPithyPrint;
|
||||||
|
|
||||||
#include <srs_app_st.hpp>
|
#include <srs_app_st.hpp>
|
||||||
|
|
|
@ -51,7 +51,7 @@ class SrsStSocket;
|
||||||
class SrsRtmpClient;
|
class SrsRtmpClient;
|
||||||
class SrsRawH264Stream;
|
class SrsRawH264Stream;
|
||||||
class SrsRawAacStream;
|
class SrsRawAacStream;
|
||||||
class SrsRawAacStreamCodec;
|
struct SrsRawAacStreamCodec;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
class SrsCodecSample;
|
class SrsCodecSample;
|
||||||
class SrsSimpleBuffer;
|
class SrsSimpleBuffer;
|
||||||
|
|
|
@ -2086,7 +2086,6 @@ char srs_utils_flv_audio_aac_packet_type(char* data, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int8_t aac_packet_type = data[1];
|
u_int8_t aac_packet_type = data[1];
|
||||||
aac_packet_type = aac_packet_type;
|
|
||||||
if (aac_packet_type > 1) {
|
if (aac_packet_type > 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,6 +534,85 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy()
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsPacket::SrsPacket()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsPacket::~SrsPacket()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPacket::encode(int& psize, char*& ppayload)
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
int size = get_size();
|
||||||
|
char* payload = NULL;
|
||||||
|
|
||||||
|
SrsStream stream;
|
||||||
|
|
||||||
|
if (size > 0) {
|
||||||
|
payload = new char[size];
|
||||||
|
|
||||||
|
if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("initialize the stream failed. ret=%d", ret);
|
||||||
|
srs_freep(payload);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ret = encode_packet(&stream)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("encode the packet failed. ret=%d", ret);
|
||||||
|
srs_freep(payload);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
psize = size;
|
||||||
|
ppayload = payload;
|
||||||
|
srs_verbose("encode the packet success. size=%d", size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPacket::decode(SrsStream* stream)
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
srs_assert(stream != NULL);
|
||||||
|
|
||||||
|
ret = ERROR_SYSTEM_PACKET_INVALID;
|
||||||
|
srs_error("current packet is not support to decode. ret=%d", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPacket::get_prefer_cid()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPacket::get_message_type()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPacket::get_size()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPacket::encode_packet(SrsStream* stream)
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
srs_assert(stream != NULL);
|
||||||
|
|
||||||
|
ret = ERROR_SYSTEM_PACKET_INVALID;
|
||||||
|
srs_error("current packet is not support to encode. ret=%d", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
SrsProtocol::AckWindowSize::AckWindowSize()
|
SrsProtocol::AckWindowSize::AckWindowSize()
|
||||||
{
|
{
|
||||||
ack_window_size = 0;
|
ack_window_size = 0;
|
||||||
|
@ -2020,85 +2099,6 @@ SrsChunkStream::~SrsChunkStream()
|
||||||
srs_freep(msg);
|
srs_freep(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsPacket::SrsPacket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsPacket::~SrsPacket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPacket::encode(int& psize, char*& ppayload)
|
|
||||||
{
|
|
||||||
int ret = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
int size = get_size();
|
|
||||||
char* payload = NULL;
|
|
||||||
|
|
||||||
SrsStream stream;
|
|
||||||
|
|
||||||
if (size > 0) {
|
|
||||||
payload = new char[size];
|
|
||||||
|
|
||||||
if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("initialize the stream failed. ret=%d", ret);
|
|
||||||
srs_freep(payload);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = encode_packet(&stream)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("encode the packet failed. ret=%d", ret);
|
|
||||||
srs_freep(payload);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
psize = size;
|
|
||||||
ppayload = payload;
|
|
||||||
srs_verbose("encode the packet success. size=%d", size);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPacket::decode(SrsStream* stream)
|
|
||||||
{
|
|
||||||
int ret = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
srs_assert(stream != NULL);
|
|
||||||
|
|
||||||
ret = ERROR_SYSTEM_PACKET_INVALID;
|
|
||||||
srs_error("current packet is not support to decode. ret=%d", ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPacket::get_prefer_cid()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPacket::get_message_type()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPacket::get_size()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPacket::encode_packet(SrsStream* stream)
|
|
||||||
{
|
|
||||||
int ret = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
srs_assert(stream != NULL);
|
|
||||||
|
|
||||||
ret = ERROR_SYSTEM_PACKET_INVALID;
|
|
||||||
srs_error("current packet is not support to encode. ret=%d", ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConnectAppPacket::SrsConnectAppPacket()
|
SrsConnectAppPacket::SrsConnectAppPacket()
|
||||||
{
|
{
|
||||||
command_name = RTMP_AMF0_COMMAND_CONNECT;
|
command_name = RTMP_AMF0_COMMAND_CONNECT;
|
||||||
|
|
|
@ -317,6 +317,60 @@ public:
|
||||||
virtual SrsSharedPtrMessage* copy();
|
virtual SrsSharedPtrMessage* copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the decoded message payload.
|
||||||
|
* @remark we seperate the packet from message,
|
||||||
|
* for the packet focus on logic and domain data,
|
||||||
|
* the message bind to the protocol and focus on protocol, such as header.
|
||||||
|
* we can merge the message and packet, using OOAD hierachy, packet extends from message,
|
||||||
|
* it's better for me to use components -- the message use the packet as payload.
|
||||||
|
*/
|
||||||
|
class SrsPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SrsPacket();
|
||||||
|
virtual ~SrsPacket();
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* the subpacket can override this encode,
|
||||||
|
* for example, video and audio will directly set the payload withou memory copy,
|
||||||
|
* other packet which need to serialize/encode to bytes by override the
|
||||||
|
* get_size and encode_packet.
|
||||||
|
*/
|
||||||
|
virtual int encode(int& size, char*& payload);
|
||||||
|
// decode functions for concrete packet to override.
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* subpacket must override to decode packet from stream.
|
||||||
|
* @remark never invoke the super.decode, it always failed.
|
||||||
|
*/
|
||||||
|
virtual int decode(SrsStream* stream);
|
||||||
|
// encode functions for concrete packet to override.
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* the cid(chunk id) specifies the chunk to send data over.
|
||||||
|
* generally, each message perfer some cid, for example,
|
||||||
|
* all protocol control messages perfer RTMP_CID_ProtocolControl,
|
||||||
|
* SrsSetWindowAckSizePacket is protocol control message.
|
||||||
|
*/
|
||||||
|
virtual int get_prefer_cid();
|
||||||
|
/**
|
||||||
|
* subpacket must override to provide the right message type.
|
||||||
|
* the message type set the RTMP message type in header.
|
||||||
|
*/
|
||||||
|
virtual int get_message_type();
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* subpacket can override to calc the packet size.
|
||||||
|
*/
|
||||||
|
virtual int get_size();
|
||||||
|
/**
|
||||||
|
* subpacket can override to encode the payload to stream.
|
||||||
|
* @remark never invoke the super.encode_packet, it always failed.
|
||||||
|
*/
|
||||||
|
virtual int encode_packet(SrsStream* stream);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the protocol provides the rtmp-message-protocol services,
|
* the protocol provides the rtmp-message-protocol services,
|
||||||
* to recv RTMP message from RTMP chunk stream,
|
* to recv RTMP message from RTMP chunk stream,
|
||||||
|
@ -662,60 +716,6 @@ public:
|
||||||
virtual ~SrsChunkStream();
|
virtual ~SrsChunkStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* the decoded message payload.
|
|
||||||
* @remark we seperate the packet from message,
|
|
||||||
* for the packet focus on logic and domain data,
|
|
||||||
* the message bind to the protocol and focus on protocol, such as header.
|
|
||||||
* we can merge the message and packet, using OOAD hierachy, packet extends from message,
|
|
||||||
* it's better for me to use components -- the message use the packet as payload.
|
|
||||||
*/
|
|
||||||
class SrsPacket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SrsPacket();
|
|
||||||
virtual ~SrsPacket();
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* the subpacket can override this encode,
|
|
||||||
* for example, video and audio will directly set the payload withou memory copy,
|
|
||||||
* other packet which need to serialize/encode to bytes by override the
|
|
||||||
* get_size and encode_packet.
|
|
||||||
*/
|
|
||||||
virtual int encode(int& size, char*& payload);
|
|
||||||
// decode functions for concrete packet to override.
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* subpacket must override to decode packet from stream.
|
|
||||||
* @remark never invoke the super.decode, it always failed.
|
|
||||||
*/
|
|
||||||
virtual int decode(SrsStream* stream);
|
|
||||||
// encode functions for concrete packet to override.
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* the cid(chunk id) specifies the chunk to send data over.
|
|
||||||
* generally, each message perfer some cid, for example,
|
|
||||||
* all protocol control messages perfer RTMP_CID_ProtocolControl,
|
|
||||||
* SrsSetWindowAckSizePacket is protocol control message.
|
|
||||||
*/
|
|
||||||
virtual int get_prefer_cid();
|
|
||||||
/**
|
|
||||||
* subpacket must override to provide the right message type.
|
|
||||||
* the message type set the RTMP message type in header.
|
|
||||||
*/
|
|
||||||
virtual int get_message_type();
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* subpacket can override to calc the packet size.
|
|
||||||
*/
|
|
||||||
virtual int get_size();
|
|
||||||
/**
|
|
||||||
* subpacket can override to encode the payload to stream.
|
|
||||||
* @remark never invoke the super.encode_packet, it always failed.
|
|
||||||
*/
|
|
||||||
virtual int encode_packet(SrsStream* stream);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 4.1.1. connect
|
* 4.1.1. connect
|
||||||
* The client sends the connect command to the server to request
|
* The client sends the connect command to the server to request
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue