OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "modules/video_coding/frame_buffer2.h" |
| 12 |
| 13 #include "modules/video_coding/jitter_estimator.h" |
| 14 #include "modules/video_coding/timing.h" |
| 15 #include "system_wrappers/include/clock.h" |
| 16 |
| 17 namespace webrtc { |
| 18 |
| 19 namespace { |
| 20 template <typename T> |
| 21 T ReadNum(const uint8_t* data, size_t* offset, size_t max_size) { |
| 22 RTC_CHECK(*offset + sizeof(T) < max_size); |
| 23 T res = *reinterpret_cast<const T*>(data + *offset); |
| 24 *offset += sizeof(T); |
| 25 return res; |
| 26 } |
| 27 } // namespace |
| 28 |
| 29 class FuzzyFrameObject : public video_coding::FrameObject { |
| 30 public: |
| 31 FuzzyFrameObject() {} |
| 32 ~FuzzyFrameObject() {} |
| 33 |
| 34 bool GetBitstream(uint8_t* destination) const override { return false; } |
| 35 uint32_t Timestamp() const override { return timestamp; } |
| 36 int64_t ReceivedTime() const override { return 0; } |
| 37 int64_t RenderTime() const override { return _renderTimeMs; } |
| 38 }; |
| 39 |
| 40 void FuzzOneInput(const uint8_t* data, size_t size) { |
| 41 Clock* clock = Clock::GetRealTimeClock(); |
| 42 VCMJitterEstimator jitter_estimator(clock, 0, 0); |
| 43 VCMTiming timing(clock); |
| 44 video_coding::FrameBuffer frame_buffer(clock, &jitter_estimator, &timing, |
| 45 nullptr); |
| 46 |
| 47 size_t offset = 0; |
| 48 while (true) { |
| 49 if (offset + 1 >= size) |
| 50 return; |
| 51 |
| 52 if (ReadNum<uint8_t>(data, &offset, size) & 1) { |
| 53 if (offset + 14 >= size) |
| 54 return; |
| 55 |
| 56 std::unique_ptr<FuzzyFrameObject> frame(new FuzzyFrameObject()); |
| 57 frame->picture_id = ReadNum<int64_t>(data, &offset, size); |
| 58 frame->spatial_layer = ReadNum<uint8_t>(data, &offset, size) & 7; |
| 59 frame->timestamp = ReadNum<uint32_t>(data, &offset, size); |
| 60 frame->num_references = ReadNum<uint8_t>(data, &offset, size) % 6; |
| 61 |
| 62 if (offset + frame->num_references * 8 >= size) |
| 63 return; |
| 64 for (size_t r = 0; r < frame->num_references; ++r) |
| 65 frame->references[r] = ReadNum<int64_t>(data, &offset, size); |
| 66 |
| 67 frame_buffer.InsertFrame(std::move(frame)); |
| 68 |
| 69 } else { |
| 70 if (offset + 1 >= size) |
| 71 return; |
| 72 |
| 73 int64_t wait_ms = ReadNum<uint8_t>(data, &offset, size) & 7; |
| 74 std::unique_ptr<video_coding::FrameObject> frame(new FuzzyFrameObject()); |
| 75 |
| 76 frame_buffer.NextFrame(wait_ms, &frame); |
| 77 } |
| 78 } |
| 79 } |
| 80 |
| 81 } // namespace webrtc |
OLD | NEW |