winlin

add shared ptr message

@@ -61,4 +61,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -61,4 +61,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61 } \ 61 } \
62 (void)0 62 (void)0
63 63
  64 +// server info.
  65 +#define RTMP_SIG_SRS_NAME "srs(simple rtmp server)"
  66 +#define RTMP_SIG_SRS_URL "https://github.com/winlinvip/simple-rtmp-server"
  67 +#define RTMP_SIG_SRS_VERSION "0.1"
  68 +
64 #endif 69 #endif
@@ -238,7 +238,7 @@ int SrsClient::streaming_publish(SrsSource* source) @@ -238,7 +238,7 @@ int SrsClient::streaming_publish(SrsSource* source)
238 SrsPacket* pkt = msg->get_packet(); 238 SrsPacket* pkt = msg->get_packet();
239 if (dynamic_cast<SrsOnMetaDataPacket*>(pkt)) { 239 if (dynamic_cast<SrsOnMetaDataPacket*>(pkt)) {
240 SrsOnMetaDataPacket* metadata = dynamic_cast<SrsOnMetaDataPacket*>(pkt); 240 SrsOnMetaDataPacket* metadata = dynamic_cast<SrsOnMetaDataPacket*>(pkt);
241 - if ((ret = source->on_meta_data(metadata)) != ERROR_SUCCESS) { 241 + if ((ret = source->on_meta_data(msg, metadata)) != ERROR_SUCCESS) {
242 srs_error("process onMetaData message failed. ret=%d", ret); 242 srs_error("process onMetaData message failed. ret=%d", ret);
243 return ret; 243 return ret;
244 } 244 }
@@ -1089,6 +1089,14 @@ int SrsMessage::encode_packet() @@ -1089,6 +1089,14 @@ int SrsMessage::encode_packet()
1089 return packet->encode(size, (char*&)payload); 1089 return packet->encode(size, (char*&)payload);
1090 } 1090 }
1091 1091
  1092 +SrsSharedMessage::SrsSharedMessage()
  1093 +{
  1094 +}
  1095 +
  1096 +SrsSharedMessage::~SrsSharedMessage()
  1097 +{
  1098 +}
  1099 +
1092 SrsPacket::SrsPacket() 1100 SrsPacket::SrsPacket()
1093 { 1101 {
1094 } 1102 }
@@ -285,6 +285,17 @@ public: @@ -285,6 +285,17 @@ public:
285 }; 285 };
286 286
287 /** 287 /**
  288 +* shared ptr message.
  289 +* for audio/video/data message that need less memory copy.
  290 +*/
  291 +class SrsSharedMessage : public SrsMessage
  292 +{
  293 +public:
  294 + SrsSharedMessage();
  295 + virtual ~SrsSharedMessage();
  296 +};
  297 +
  298 +/**
288 * the decoded message payload. 299 * the decoded message payload.
289 */ 300 */
290 class SrsPacket 301 class SrsPacket
@@ -35,11 +35,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -35,11 +35,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 */ 35 */
36 #define RTMP_SIG_FMS_VER "3,5,3,888" 36 #define RTMP_SIG_FMS_VER "3,5,3,888"
37 #define RTMP_SIG_AMF0_VER 0 37 #define RTMP_SIG_AMF0_VER 0
38 -#define RTMP_SIG_SRS_NAME "srs(simple rtmp server)"  
39 -#define RTMP_SIG_SRS_URL "https://github.com/winlinvip/simple-rtmp-server"  
40 -#define RTMP_SIG_SRS_VERSION "0.1"  
41 #define RTMP_SIG_CLIENT_ID "ASAICiss" 38 #define RTMP_SIG_CLIENT_ID "ASAICiss"
42 39
  40 +/**
  41 +* onStatus consts.
  42 +*/
43 #define StatusLevel "level" 43 #define StatusLevel "level"
44 #define StatusCode "code" 44 #define StatusCode "code"
45 #define StatusDescription "description" 45 #define StatusDescription "description"
@@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 25
26 #include <srs_core_log.hpp> 26 #include <srs_core_log.hpp>
27 #include <srs_core_protocol.hpp> 27 #include <srs_core_protocol.hpp>
  28 +#include <srs_core_amf0.hpp>
28 29
29 std::map<std::string, SrsSource*> SrsSource::pool; 30 std::map<std::string, SrsSource*> SrsSource::pool;
30 31
@@ -64,9 +65,13 @@ SrsSource::~SrsSource() @@ -64,9 +65,13 @@ SrsSource::~SrsSource()
64 { 65 {
65 } 66 }
66 67
67 -int SrsSource::on_meta_data(SrsOnMetaDataPacket* metadata) 68 +int SrsSource::on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata)
68 { 69 {
69 int ret = ERROR_SUCCESS; 70 int ret = ERROR_SUCCESS;
  71 +
  72 + metadata->metadata->set("server",
  73 + new SrsAmf0String(RTMP_SIG_SRS_NAME""RTMP_SIG_SRS_VERSION));
  74 +
70 return ret; 75 return ret;
71 } 76 }
72 77
@@ -75,7 +75,7 @@ public: @@ -75,7 +75,7 @@ public:
75 SrsSource(std::string _stream_url); 75 SrsSource(std::string _stream_url);
76 virtual ~SrsSource(); 76 virtual ~SrsSource();
77 public: 77 public:
78 - virtual int on_meta_data(SrsOnMetaDataPacket* metadata); 78 + virtual int on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata);
79 virtual int on_audio(SrsMessage* audio); 79 virtual int on_audio(SrsMessage* audio);
80 virtual int on_video(SrsMessage* video); 80 virtual int on_video(SrsMessage* video);
81 public: 81 public: