2013-04-25 21:45:29 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_VIDEO_CODING_TEST_STREAM_GENERATOR_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_TEST_STREAM_GENERATOR_H_
|
2013-04-25 21:45:29 +00:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2013-04-25 21:45:29 +00:00
|
|
|
#include <list>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/packet.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/constructor_magic.h"
|
2013-04-25 21:45:29 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
const unsigned int kDefaultBitrateKbps = 1000;
|
2013-05-07 12:36:21 +00:00
|
|
|
const unsigned int kDefaultFrameRate = 25;
|
2013-04-25 21:45:29 +00:00
|
|
|
const unsigned int kMaxPacketSize = 1500;
|
2013-09-13 19:17:54 +00:00
|
|
|
const unsigned int kFrameSize =
|
|
|
|
|
(kDefaultBitrateKbps + kDefaultFrameRate * 4) / (kDefaultFrameRate * 8);
|
2013-05-07 19:16:33 +00:00
|
|
|
const int kDefaultFramePeriodMs = 1000 / kDefaultFrameRate;
|
2013-04-25 21:45:29 +00:00
|
|
|
|
|
|
|
|
class StreamGenerator {
|
|
|
|
|
public:
|
2015-06-05 14:45:05 -07:00
|
|
|
StreamGenerator(uint16_t start_seq_num, int64_t current_time);
|
|
|
|
|
void Init(uint16_t start_seq_num, int64_t current_time);
|
2013-04-25 21:45:29 +00:00
|
|
|
|
2021-08-09 13:02:57 +02:00
|
|
|
// `time_ms` denotes the timestamp you want to put on the frame, and the unit
|
|
|
|
|
// is millisecond. GenerateFrame will translate `time_ms` into a 90kHz
|
2015-06-19 09:17:00 -07:00
|
|
|
// timestamp and put it on the frame.
|
2019-03-07 10:18:23 +01:00
|
|
|
void GenerateFrame(VideoFrameType type,
|
2013-09-13 19:17:54 +00:00
|
|
|
int num_media_packets,
|
|
|
|
|
int num_empty_packets,
|
2015-06-19 09:17:00 -07:00
|
|
|
int64_t time_ms);
|
2013-04-25 21:45:29 +00:00
|
|
|
|
|
|
|
|
bool PopPacket(VCMPacket* packet, int index);
|
2013-06-17 07:13:16 +00:00
|
|
|
void DropLastPacket();
|
2013-04-25 21:45:29 +00:00
|
|
|
|
|
|
|
|
bool GetPacket(VCMPacket* packet, int index);
|
|
|
|
|
|
|
|
|
|
bool NextPacket(VCMPacket* packet);
|
|
|
|
|
|
|
|
|
|
uint16_t NextSequenceNumber() const;
|
|
|
|
|
|
|
|
|
|
int PacketsRemaining() const;
|
|
|
|
|
|
|
|
|
|
private:
|
2015-06-05 14:45:05 -07:00
|
|
|
VCMPacket GeneratePacket(uint16_t sequence_number,
|
|
|
|
|
uint32_t timestamp,
|
|
|
|
|
unsigned int size,
|
|
|
|
|
bool first_packet,
|
|
|
|
|
bool marker_bit,
|
2019-03-07 10:18:23 +01:00
|
|
|
VideoFrameType type);
|
2015-06-05 14:45:05 -07:00
|
|
|
|
2013-04-25 21:45:29 +00:00
|
|
|
std::list<VCMPacket>::iterator GetPacketIterator(int index);
|
|
|
|
|
|
|
|
|
|
std::list<VCMPacket> packets_;
|
|
|
|
|
uint16_t sequence_number_;
|
|
|
|
|
int64_t start_time_;
|
2015-06-05 15:02:36 -07:00
|
|
|
uint8_t packet_buffer_[kMaxPacketSize];
|
2013-04-25 21:45:29 +00:00
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(StreamGenerator);
|
2013-04-25 21:45:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_VIDEO_CODING_TEST_STREAM_GENERATOR_H_
|