OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2014 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_ | |
13 | |
14 #include <vector> | |
15 | |
16 #include "webrtc/base/constructormagic.h" | |
17 #include "webrtc/base/scoped_ptr.h" | |
18 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" | |
19 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" | |
20 #include "webrtc/system_wrappers/interface/clock.h" | |
21 | |
22 namespace webrtc { | |
23 | |
24 namespace test { | |
25 class InputAudioFile; | |
26 class Packet; | |
27 | |
28 class AcmSendTest : public AudioPacketizationCallback, public PacketSource { | |
29 public: | |
30 AcmSendTest(InputAudioFile* audio_source, | |
31 int source_rate_hz, | |
32 int test_duration_ms); | |
33 virtual ~AcmSendTest() {} | |
34 | |
35 // Registers the send codec. Returns true on success, false otherwise. | |
36 bool RegisterCodec(int codec_type, | |
37 int channels, | |
38 int payload_type, | |
39 int frame_size_samples); | |
40 | |
41 // Returns the next encoded packet. Returns NULL if the test duration was | |
42 // exceeded. Ownership of the packet is handed over to the caller. | |
43 // Inherited from PacketSource. | |
44 Packet* NextPacket() override; | |
45 | |
46 // Inherited from AudioPacketizationCallback. | |
47 int32_t SendData(FrameType frame_type, | |
48 uint8_t payload_type, | |
49 uint32_t timestamp, | |
50 const uint8_t* payload_data, | |
51 size_t payload_len_bytes, | |
52 const RTPFragmentationHeader* fragmentation) override; | |
53 | |
54 private: | |
55 static const int kBlockSizeMs = 10; | |
56 | |
57 // Creates a Packet object from the last packet produced by ACM (and received | |
58 // through the SendData method as a callback). Ownership of the new Packet | |
59 // object is transferred to the caller. | |
60 Packet* CreatePacket(); | |
61 | |
62 SimulatedClock clock_; | |
63 rtc::scoped_ptr<AudioCoding> acm_; | |
64 InputAudioFile* audio_source_; | |
65 int source_rate_hz_; | |
66 const size_t input_block_size_samples_; | |
67 AudioFrame input_frame_; | |
68 bool codec_registered_; | |
69 int test_duration_ms_; | |
70 // The following member variables are set whenever SendData() is called. | |
71 FrameType frame_type_; | |
72 int payload_type_; | |
73 uint32_t timestamp_; | |
74 uint16_t sequence_number_; | |
75 std::vector<uint8_t> last_payload_vec_; | |
76 | |
77 RTC_DISALLOW_COPY_AND_ASSIGN(AcmSendTest); | |
78 }; | |
79 | |
80 } // namespace test | |
81 } // namespace webrtc | |
82 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_ | |
OLD | NEW |