| 574 | } |
| 575 | |
| 576 | bool ReadAMFObject(google::protobuf::Message* msg, AMFInputStream* stream) { |
| 577 | uint8_t marker; |
| 578 | if (stream->cut_u8(&marker) != 1u) { |
| 579 | LOG(ERROR) << "stream is not long enough"; |
| 580 | return false; |
| 581 | } |
| 582 | if ((AMFMarker)marker == AMF_MARKER_OBJECT) { |
| 583 | if (!ReadAMFObjectBody(msg, stream)) { |
| 584 | return false; |
| 585 | } |
| 586 | } else if ((AMFMarker)marker == AMF_MARKER_ECMA_ARRAY) { |
| 587 | if (!ReadAMFEcmaArrayBody(msg, stream)) { |
| 588 | return false; |
| 589 | } |
| 590 | } else if ((AMFMarker)marker != AMF_MARKER_NULL) { |
| 591 | // Notice that NULL is treated as an object w/o any fields. |
| 592 | LOG(ERROR) << "Expected object/null, actually " << marker2str(marker); |
| 593 | return false; |
| 594 | } |
| 595 | if (!msg->IsInitialized()) { |
| 596 | LOG(ERROR) << "Missing required fields: " |
| 597 | << msg->InitializationErrorString(); |
| 598 | return false; |
| 599 | } |
| 600 | return true; |
| 601 | } |
| 602 | |
| 603 | // [Reading AMFObject] |
| 604 | |