Changeset 28343
- Timestamp:
- 01/13/09 02:09:03 (4 years ago)
- Location:
- lang/c/librtmp
- Files:
-
- 3 modified
-
amf_packet.c (modified) (13 diffs)
-
amf_packet.h (modified) (1 diff)
-
main.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/librtmp/amf_packet.c
r28236 r28343 29 29 30 30 31 static amf_packet_t *amf_packet_ create_number(31 static amf_packet_t *amf_packet_analyze_number( 32 32 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size); 33 static amf_packet_t *amf_packet_ create_boolean(33 static amf_packet_t *amf_packet_analyze_boolean( 34 34 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size); 35 static amf_packet_t *amf_packet_ create_string(35 static amf_packet_t *amf_packet_analyze_string( 36 36 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size); 37 static amf_packet_t *amf_packet_ create_object(37 static amf_packet_t *amf_packet_analyze_object( 38 38 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size); 39 static amf_packet_t *amf_packet_ create_null();40 static amf_packet_t *amf_packet_ create_undefined();41 42 43 amf_packet_t *amf_packet_ create(39 static amf_packet_t *amf_packet_analyze_null(); 40 static amf_packet_t *amf_packet_analyze_undefined(); 41 42 43 amf_packet_t *amf_packet_analyze( 44 44 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size) 45 45 { … … 54 54 switch (raw_data[0]) { 55 55 case AMF_DATATYPE_NUMBER: 56 amf = amf_packet_ create_number(56 amf = amf_packet_analyze_number( 57 57 raw_data, raw_data_size, packet_size); 58 58 return amf; 59 59 case AMF_DATATYPE_BOOLEAN: 60 amf = amf_packet_ create_boolean(60 amf = amf_packet_analyze_boolean( 61 61 raw_data, raw_data_size, packet_size); 62 62 return amf; 63 63 case AMF_DATATYPE_STRING: 64 amf = amf_packet_ create_string(64 amf = amf_packet_analyze_string( 65 65 raw_data, raw_data_size, packet_size); 66 66 return amf; 67 67 case AMF_DATATYPE_OBJECT: 68 amf = amf_packet_ create_object(68 amf = amf_packet_analyze_object( 69 69 raw_data, raw_data_size, packet_size); 70 70 return amf; 71 71 case AMF_DATATYPE_NULL: 72 amf = amf_packet_ create_null();72 amf = amf_packet_analyze_null(); 73 73 return amf; 74 74 case AMF_DATATYPE_UNDEFINED: 75 amf = amf_packet_ create_undefined();75 amf = amf_packet_analyze_undefined(); 76 76 return amf; 77 77 case AMF_DATATYPE_OBJECT_END: … … 85 85 } 86 86 87 amf_packet_t *amf_packet_ create_number(87 amf_packet_t *amf_packet_analyze_number( 88 88 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size) 89 89 { … … 91 91 unsigned char number_data[8]; 92 92 93 printf("!!!!!!!: 0\n");94 93 /* FIXME!: big-endian and little-endian */ 95 94 if (raw_data_size < 9) { … … 100 99 } 101 100 102 printf("!!!!!!!: 1\n");103 101 amf = (amf_packet_t*)malloc(sizeof(amf_packet_number_t)); 104 printf("!!!!!!!: 2\n");105 102 amf->datatype = AMF_DATATYPE_NUMBER; 106 printf("!!!!!!!: 3\n");107 103 number_data[0] = raw_data[8]; 108 104 number_data[1] = raw_data[7]; … … 113 109 number_data[6] = raw_data[2]; 114 110 number_data[7] = raw_data[1]; 115 printf("!!!!!!!: 4\n");116 111 memmove(&(amf->number.number), number_data, 8); 117 112 printf("AMF NUMBER:: %f\n", amf->number.number); 118 printf("!!!!!!!: 5\n");119 113 if (packet_size) { 120 114 *packet_size = 9; 121 115 } 122 printf("!!!!!!!: 6\n"); 123 return amf; 124 } 125 126 127 amf_packet_t *amf_packet_create_boolean( 116 return amf; 117 } 118 119 120 amf_packet_t *amf_packet_analyze_boolean( 128 121 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size) 129 122 { … … 150 143 } 151 144 152 amf_packet_t *amf_packet_ create_string(145 amf_packet_t *amf_packet_analyze_string( 153 146 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size) 154 147 { … … 192 185 } 193 186 194 amf_packet_t *amf_packet_ create_object(187 amf_packet_t *amf_packet_analyze_object( 195 188 unsigned char *raw_data, size_t raw_data_size, size_t *packet_size) 196 189 { … … 217 210 string_length += raw_data[raw_data_position + 1]; 218 211 if (string_length == 0 && raw_data[raw_data_position + 2] == 0x09) { 219 printf(" end\n");212 printf("object end\n"); 220 213 break; 221 214 } … … 249 242 } 250 243 251 amf_packet_t *amf_packet_ create_null()244 amf_packet_t *amf_packet_analyze_null() 252 245 { 253 246 amf_packet_t *amf; … … 261 254 } 262 255 263 amf_packet_t *amf_packet_ create_undefined()256 amf_packet_t *amf_packet_analyze_undefined() 264 257 { 265 258 amf_packet_t *amf; … … 276 269 void amf_packet_free(amf_packet_t *amf) 277 270 { 271 amf_packet_object_property_t *property; 272 amf_packet_object_property_t *next; 273 278 274 switch( amf->datatype ){ 279 275 case AMF_DATATYPE_NUMBER: … … 285 281 break; 286 282 case AMF_DATATYPE_OBJECT: 283 property = amf->object.properties; 284 while (property) { 285 next = property->next; 286 free(property->key); 287 amf_packet_free(property->value); 288 free(property); 289 property = next; 290 } 287 291 break; 288 292 case AMF_DATATYPE_NULL: -
lang/c/librtmp/amf_packet.h
r28235 r28343 121 121 122 122 123 extern amf_packet_t *amf_packet_ create(123 extern amf_packet_t *amf_packet_analyze( 124 124 unsigned char *data, size_t data_size, size_t *packet_size); 125 125 extern void amf_packet_free(amf_packet_t *amf); -
lang/c/librtmp/main.c
r28236 r28343 17 17 printf("Hello, RTMP!\n"); 18 18 19 /* 19 20 { 20 /* number */ 21 // unsigned char number_temp[] = { 22 // 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 23 // amf_packet_create(number_temp, sizeof(number_temp), NULL); 24 /* boolean */ 25 // unsigned char boolean_temp[] = {0x01, 0x01}; 26 // amf_packet_create(boolean_temp, sizeof(boolean_temp), NULL); 27 /* string */ 28 // unsigned char string_temp[] = {0x02, 0x00, 0x04, 0x69, 0x74, 0x6B, 0x7A}; 29 // amf_packet_create(string_temp, sizeof(string_temp), NULL); 30 /*object*/ 21 amf_packet_t *amf; 22 // number 23 unsigned char number_temp[] = { 24 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 25 amf = amf_packet_analyze(number_temp, sizeof(number_temp), NULL); 26 amf_packet_free(amf); 27 // boolean 28 unsigned char boolean_temp[] = {0x01, 0x01}; 29 amf = amf_packet_analyze(boolean_temp, sizeof(boolean_temp), NULL); 30 amf_packet_free(amf); 31 // string 32 unsigned char string_temp[] = {0x02, 0x00, 0x04, 0x69, 0x74, 0x6B, 0x7A}; 33 amf = amf_packet_analyze(string_temp, sizeof(string_temp), NULL); 34 amf_packet_free(amf); 35 // object 31 36 unsigned char object_temp[] = { 32 37 0x03, 0x00, 0x06, 0x66, 0x6D, 0x73, 0x56, 0x65, … … 37 42 0x40, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 43 0x00, 0x00, 0x09}; 39 amf_packet_create(object_temp, sizeof(object_temp), NULL); 40 /*null*/ 41 // unsigned char null_temp[] = {0x05}; 42 // amf_packet_create(null_temp, sizeof(null_temp), NULL); 43 /*undefined*/ 44 // unsigned char undefined_temp[] = {0x06}; 45 // amf_packet_create(undefined_temp, sizeof(undefined_temp), NULL); 46 /*object_end*/ 47 // unsigned char object_end_temp[] = {0x00, 0x00, 0x09}; 48 // amf_packet_create(object_end_temp, sizeof(object_end_temp), NULL); 44 amf = amf_packet_analyze(object_temp, sizeof(object_temp), NULL); 45 amf_packet_free(amf); 46 // null 47 unsigned char null_temp[] = {0x05}; 48 amf = amf_packet_analyze(null_temp, sizeof(null_temp), NULL); 49 amf_packet_free(amf); 49 50 } 51 */ 50 52 51 53 rc = rtmp_client_create("192.168.157.128", 1935);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)