winlin

fix objectEncoding bug, default to AMF0, change to AMF3 if required.

@@ -96,7 +96,7 @@ int SrsClient::do_cycle() @@ -96,7 +96,7 @@ int SrsClient::do_cycle()
96 } 96 }
97 srs_verbose("set peer bandwidth success"); 97 srs_verbose("set peer bandwidth success");
98 98
99 - if ((ret = rtmp->response_connect_app()) != ERROR_SUCCESS) { 99 + if ((ret = rtmp->response_connect_app(req)) != ERROR_SUCCESS) {
100 srs_error("response connect app failed. ret=%d", ret); 100 srs_error("response connect app failed. ret=%d", ret);
101 return ret; 101 return ret;
102 } 102 }
@@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 * the signature for packets to client. 34 * the signature for packets to client.
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 3 37 +#define RTMP_SIG_AMF0_VER 0
38 #define RTMP_SIG_SRS_NAME "srs(simple rtmp server)" 38 #define RTMP_SIG_SRS_NAME "srs(simple rtmp server)"
39 #define RTMP_SIG_SRS_URL "https://github.com/winlinvip/simple-rtmp-server" 39 #define RTMP_SIG_SRS_URL "https://github.com/winlinvip/simple-rtmp-server"
40 #define RTMP_SIG_SRS_VERSION "0.1" 40 #define RTMP_SIG_SRS_VERSION "0.1"
@@ -53,6 +53,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -53,6 +53,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 #define StatusCodeStreamStart "NetStream.Play.Start" 53 #define StatusCodeStreamStart "NetStream.Play.Start"
54 #define StatusCodeDataStart "NetStream.Data.Start" 54 #define StatusCodeDataStart "NetStream.Data.Start"
55 55
  56 +SrsRequest::SrsRequest()
  57 +{
  58 + objectEncoding = RTMP_SIG_AMF0_VER;
  59 +}
  60 +
  61 +SrsRequest::~SrsRequest()
  62 +{
  63 +}
  64 +
56 int SrsRequest::discovery_app() 65 int SrsRequest::discovery_app()
57 { 66 {
58 int ret = ERROR_SUCCESS; 67 int ret = ERROR_SUCCESS;
@@ -183,6 +192,11 @@ int SrsRtmp::connect_app(SrsRequest* req) @@ -183,6 +192,11 @@ int SrsRtmp::connect_app(SrsRequest* req)
183 if ((prop = pkt->command_object->ensure_property_string("swfUrl")) != NULL) { 192 if ((prop = pkt->command_object->ensure_property_string("swfUrl")) != NULL) {
184 req->swfUrl = srs_amf0_convert<SrsAmf0String>(prop)->value; 193 req->swfUrl = srs_amf0_convert<SrsAmf0String>(prop)->value;
185 } 194 }
  195 +
  196 + if ((prop = pkt->command_object->ensure_property_string("objectEncoding")) != NULL) {
  197 + req->objectEncoding = srs_amf0_convert<SrsAmf0Number>(prop)->value;
  198 + }
  199 +
186 srs_info("get connect app message params success."); 200 srs_info("get connect app message params success.");
187 201
188 return req->discovery_app(); 202 return req->discovery_app();
@@ -228,7 +242,7 @@ int SrsRtmp::set_peer_bandwidth(int bandwidth, int type) @@ -228,7 +242,7 @@ int SrsRtmp::set_peer_bandwidth(int bandwidth, int type)
228 return ret; 242 return ret;
229 } 243 }
230 244
231 -int SrsRtmp::response_connect_app() 245 +int SrsRtmp::response_connect_app(SrsRequest* req)
232 { 246 {
233 int ret = ERROR_SUCCESS; 247 int ret = ERROR_SUCCESS;
234 248
@@ -242,7 +256,7 @@ int SrsRtmp::response_connect_app() @@ -242,7 +256,7 @@ int SrsRtmp::response_connect_app()
242 pkt->info->properties[StatusLevel] = new SrsAmf0String(StatusLevelStatus); 256 pkt->info->properties[StatusLevel] = new SrsAmf0String(StatusLevelStatus);
243 pkt->info->properties[StatusCode] = new SrsAmf0String(StatusCodeConnectSuccess); 257 pkt->info->properties[StatusCode] = new SrsAmf0String(StatusCodeConnectSuccess);
244 pkt->info->properties[StatusDescription] = new SrsAmf0String("Connection succeeded"); 258 pkt->info->properties[StatusDescription] = new SrsAmf0String("Connection succeeded");
245 - pkt->info->properties["objectEncoding"] = new SrsAmf0Number(RTMP_SIG_AMF0_VER); 259 + pkt->info->properties["objectEncoding"] = new SrsAmf0Number(req->objectEncoding);
246 SrsASrsAmf0EcmaArray* data = new SrsASrsAmf0EcmaArray(); 260 SrsASrsAmf0EcmaArray* data = new SrsASrsAmf0EcmaArray();
247 pkt->info->properties["data"] = data; 261 pkt->info->properties["data"] = data;
248 262
@@ -46,6 +46,7 @@ struct SrsRequest @@ -46,6 +46,7 @@ struct SrsRequest
46 std::string tcUrl; 46 std::string tcUrl;
47 std::string pageUrl; 47 std::string pageUrl;
48 std::string swfUrl; 48 std::string swfUrl;
  49 + double objectEncoding;
49 50
50 std::string schema; 51 std::string schema;
51 std::string vhost; 52 std::string vhost;
@@ -53,6 +54,9 @@ struct SrsRequest @@ -53,6 +54,9 @@ struct SrsRequest
53 std::string app; 54 std::string app;
54 std::string stream; 55 std::string stream;
55 56
  57 + SrsRequest();
  58 + virtual ~SrsRequest();
  59 +
56 /** 60 /**
57 * disconvery vhost/app from tcUrl. 61 * disconvery vhost/app from tcUrl.
58 */ 62 */
@@ -91,7 +95,7 @@ public: @@ -91,7 +95,7 @@ public:
91 * using the Limit type field. 95 * using the Limit type field.
92 */ 96 */
93 virtual int set_peer_bandwidth(int bandwidth, int type); 97 virtual int set_peer_bandwidth(int bandwidth, int type);
94 - virtual int response_connect_app(); 98 + virtual int response_connect_app(SrsRequest* req);
95 virtual int on_bw_done(); 99 virtual int on_bw_done();
96 /** 100 /**
97 * recv some message to identify the client. 101 * recv some message to identify the client.