mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 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 | */ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 10 | #ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_STREAM_GENERATOR_H_ |
| 11 | #define WEBRTC_MODULES_VIDEO_CODING_TEST_STREAM_GENERATOR_H_ |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 12 | |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 13 | #include <list> |
| 14 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 15 | #include "webrtc/modules/video_coding/packet.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 16 | #include "webrtc/rtc_base/constructormagic.h" |
Wan-Teh Chang | 55b6acb | 2015-06-05 15:02:36 -0700 | [diff] [blame] | 17 | #include "webrtc/typedefs.h" |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | const unsigned int kDefaultBitrateKbps = 1000; |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 22 | const unsigned int kDefaultFrameRate = 25; |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 23 | const unsigned int kMaxPacketSize = 1500; |
andresp@webrtc.org | 1f09dbe | 2013-09-13 19:17:54 +0000 | [diff] [blame] | 24 | const unsigned int kFrameSize = |
| 25 | (kDefaultBitrateKbps + kDefaultFrameRate * 4) / (kDefaultFrameRate * 8); |
stefan@webrtc.org | ef14488 | 2013-05-07 19:16:33 +0000 | [diff] [blame] | 26 | const int kDefaultFramePeriodMs = 1000 / kDefaultFrameRate; |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 27 | |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 28 | class StreamGenerator { |
| 29 | public: |
Wan-Teh Chang | 349c2bb | 2015-06-05 14:45:05 -0700 | [diff] [blame] | 30 | StreamGenerator(uint16_t start_seq_num, int64_t current_time); |
| 31 | void Init(uint16_t start_seq_num, int64_t current_time); |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 32 | |
Qiang Chen | d4cec15 | 2015-06-19 09:17:00 -0700 | [diff] [blame] | 33 | // |time_ms| denotes the timestamp you want to put on the frame, and the unit |
| 34 | // is millisecond. GenerateFrame will translate |time_ms| into a 90kHz |
| 35 | // timestamp and put it on the frame. |
andresp@webrtc.org | 1f09dbe | 2013-09-13 19:17:54 +0000 | [diff] [blame] | 36 | void GenerateFrame(FrameType type, |
| 37 | int num_media_packets, |
| 38 | int num_empty_packets, |
Qiang Chen | d4cec15 | 2015-06-19 09:17:00 -0700 | [diff] [blame] | 39 | int64_t time_ms); |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 40 | |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 41 | bool PopPacket(VCMPacket* packet, int index); |
stefan@webrtc.org | c8b29a2 | 2013-06-17 07:13:16 +0000 | [diff] [blame] | 42 | void DropLastPacket(); |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 43 | |
| 44 | bool GetPacket(VCMPacket* packet, int index); |
| 45 | |
| 46 | bool NextPacket(VCMPacket* packet); |
| 47 | |
| 48 | uint16_t NextSequenceNumber() const; |
| 49 | |
| 50 | int PacketsRemaining() const; |
| 51 | |
| 52 | private: |
Wan-Teh Chang | 349c2bb | 2015-06-05 14:45:05 -0700 | [diff] [blame] | 53 | VCMPacket GeneratePacket(uint16_t sequence_number, |
| 54 | uint32_t timestamp, |
| 55 | unsigned int size, |
| 56 | bool first_packet, |
| 57 | bool marker_bit, |
| 58 | FrameType type); |
| 59 | |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 60 | std::list<VCMPacket>::iterator GetPacketIterator(int index); |
| 61 | |
| 62 | std::list<VCMPacket> packets_; |
| 63 | uint16_t sequence_number_; |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 64 | int64_t start_time_; |
Wan-Teh Chang | 55b6acb | 2015-06-05 15:02:36 -0700 | [diff] [blame] | 65 | uint8_t packet_buffer_[kMaxPacketSize]; |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 66 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 67 | RTC_DISALLOW_COPY_AND_ASSIGN(StreamGenerator); |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | } // namespace webrtc |
| 71 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 72 | #endif // WEBRTC_MODULES_VIDEO_CODING_TEST_STREAM_GENERATOR_H_ |