Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / audio_coding / neteq / tools / packet_source.h
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_NETEQ_TOOLS_PACKET_SOURCE_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_SOURCE_H_
13
14 #include <bitset>
15
16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/typedefs.h"
18
19 namespace webrtc {
20 namespace test {
21
22 class Packet;
23
24 // Interface class for an object delivering RTP packets to test applications.
25 class PacketSource {
26  public:
27   PacketSource() : use_ssrc_filter_(false), ssrc_(0) {}
28   virtual ~PacketSource() {}
29
30   // Returns a pointer to the next packet. Returns NULL if the source is
31   // depleted, or if an error occurred.
32   virtual Packet* NextPacket() = 0;
33
34   virtual void FilterOutPayloadType(uint8_t payload_type) {
35     filter_.set(payload_type, true);
36   }
37
38   virtual void SelectSsrc(uint32_t ssrc) {
39     use_ssrc_filter_ = true;
40     ssrc_ = ssrc;
41   }
42
43  protected:
44   std::bitset<128> filter_;  // Payload type is 7 bits in the RFC.
45   // If SSRC filtering discards all packet that do not match the SSRC.
46   bool use_ssrc_filter_;  // True when SSRC filtering is active.
47   uint32_t ssrc_;  // The selected SSRC. All other SSRCs will be discarded.
48
49  private:
50   DISALLOW_COPY_AND_ASSIGN(PacketSource);
51 };
52
53 }  // namespace test
54 }  // namespace webrtc
55 #endif  // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_SOURCE_H_