winlin

decode amf0 string

@@ -95,3 +95,9 @@ std::string srs_amf0_read_string(SrsStream* stream) @@ -95,3 +95,9 @@ std::string srs_amf0_read_string(SrsStream* stream)
95 95
96 return str; 96 return str;
97 } 97 }
  98 +
  99 +double srs_amf0_read_number(SrsStream* stream)
  100 +{
  101 + return 0;
  102 +}
  103 +
@@ -36,7 +36,16 @@ class SrsStream; @@ -36,7 +36,16 @@ class SrsStream;
36 36
37 /** 37 /**
38 * read amf0 string from stream. 38 * read amf0 string from stream.
  39 +* 2.4 String Type
  40 +* string-type = string-marker UTF-8
39 */ 41 */
40 extern std::string srs_amf0_read_string(SrsStream* stream); 42 extern std::string srs_amf0_read_string(SrsStream* stream);
41 43
  44 +/**
  45 +* read amf0 number from stream.
  46 +* 2.2 Number Type
  47 +* number-type = number-marker DOUBLE
  48 +*/
  49 +extern double srs_amf0_read_number(SrsStream* stream);
  50 +
42 #endif 51 #endif
@@ -341,6 +341,14 @@ int SrsConnectAppPacket::decode(SrsStream* stream) @@ -341,6 +341,14 @@ int SrsConnectAppPacket::decode(SrsStream* stream)
341 return ret; 341 return ret;
342 } 342 }
343 343
  344 + transaction_id = srs_amf0_read_number(stream);
  345 + if (transaction_id != 1.0) {
  346 + ret = ERROR_RTMP_AMF0_DECODE;
  347 + srs_error("amf0 decode connect transaction_id failed. "
  348 + "required=%.1f, actual=%.1f, ret=%d", 1.0, transaction_id, ret);
  349 + return ret;
  350 + }
  351 +
344 return ret; 352 return ret;
345 } 353 }
346 354
@@ -163,6 +163,7 @@ private: @@ -163,6 +163,7 @@ private:
163 typedef SrsPacket super; 163 typedef SrsPacket super;
164 private: 164 private:
165 std::string command_name; 165 std::string command_name;
  166 + double transaction_id;
166 public: 167 public:
167 SrsConnectAppPacket(); 168 SrsConnectAppPacket();
168 virtual ~SrsConnectAppPacket(); 169 virtual ~SrsConnectAppPacket();