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 */
10#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TEST_STREAM_GENERATOR_H_
11#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TEST_STREAM_GENERATOR_H_
12
13#include <string.h>
14
15#include <list>
16
17#include "webrtc/modules/video_coding/main/source/packet.h"
18#include "webrtc/modules/video_coding/main/test/test_util.h"
19
20namespace webrtc {
21
22const unsigned int kDefaultBitrateKbps = 1000;
23const unsigned int kDefaultFrameRate = 25;
24const unsigned int kMaxPacketSize = 1500;
25const unsigned int kFrameSize =
26    (kDefaultBitrateKbps + kDefaultFrameRate * 4) / (kDefaultFrameRate * 8);
27const int kDefaultFramePeriodMs = 1000 / kDefaultFrameRate;
28
29class StreamGenerator {
30 public:
31  StreamGenerator(uint16_t start_seq_num,
32                  uint32_t start_timestamp,
33                  int64_t current_time);
34  void Init(uint16_t start_seq_num,
35            uint32_t start_timestamp,
36            int64_t current_time);
37
38  void GenerateFrame(FrameType type,
39                     int num_media_packets,
40                     int num_empty_packets,
41                     int64_t current_time);
42
43  VCMPacket GeneratePacket(uint16_t sequence_number,
44                           uint32_t timestamp,
45                           unsigned int size,
46                           bool first_packet,
47                           bool marker_bit,
48                           FrameType type);
49
50  bool PopPacket(VCMPacket* packet, int index);
51  void DropLastPacket();
52
53  bool GetPacket(VCMPacket* packet, int index);
54
55  bool NextPacket(VCMPacket* packet);
56
57  uint16_t NextSequenceNumber() const;
58
59  int PacketsRemaining() const;
60
61 private:
62  std::list<VCMPacket>::iterator GetPacketIterator(int index);
63
64  std::list<VCMPacket> packets_;
65  uint16_t sequence_number_;
66  uint32_t timestamp_;
67  int64_t start_time_;
68  uint8_t packet_buffer[kMaxPacketSize];
69
70  DISALLOW_COPY_AND_ASSIGN(StreamGenerator);
71};
72
73}  // namespace webrtc
74
75#endif  // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TEST_STREAM_GENERATOR_H_
76