rtp_receiver_video.h revision 5accd370e70b94517a39e622c75b794cc7a28829
1/*
2 *  Copyright (c) 2012 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_RTP_RTCP_SOURCE_RTP_RECEIVER_VIDEO_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_VIDEO_H_
13
14#include "bitrate.h"
15#include "rtp_receiver_strategy.h"
16#include "rtp_rtcp_defines.h"
17#include "rtp_utility.h"
18#include "scoped_ptr.h"
19#include "typedefs.h"
20
21namespace webrtc {
22class CriticalSectionWrapper;
23class ModuleRtpRtcpImpl;
24class ReceiverFEC;
25class RTPReceiver;
26class RTPPayloadRegistry;
27
28class RTPReceiverVideo : public RTPReceiverStrategy {
29 public:
30  RTPReceiverVideo(const WebRtc_Word32 id,
31                   const RTPPayloadRegistry* rtp_payload_registry,
32                   RtpData* data_callback);
33
34  virtual ~RTPReceiverVideo();
35
36  WebRtc_Word32 ParseRtpPacket(
37      WebRtcRTPHeader* rtp_header,
38      const ModuleRTPUtility::PayloadUnion& specificPayload,
39      const bool is_red,
40      const WebRtc_UWord8* packet,
41      const WebRtc_UWord16 packet_length,
42      const WebRtc_Word64 timestamp,
43      const bool is_first_packet);
44
45  WebRtc_Word32 GetFrequencyHz() const;
46
47  RTPAliveType ProcessDeadOrAlive(WebRtc_UWord16 lastPayloadLength) const;
48
49  bool PayloadIsCompatible(
50      const ModuleRTPUtility::Payload& payload,
51      const WebRtc_UWord32 frequency,
52      const WebRtc_UWord8 channels,
53      const WebRtc_UWord32 rate) const;
54
55  void UpdatePayloadRate(
56      ModuleRTPUtility::Payload* payload,
57      const WebRtc_UWord32 rate) const;
58
59  bool ShouldReportCsrcChanges(WebRtc_UWord8 payload_type) const;
60
61  ModuleRTPUtility::Payload* CreatePayloadType(
62      const char payloadName[RTP_PAYLOAD_NAME_SIZE],
63      const WebRtc_Word8 payloadType,
64      const WebRtc_UWord32 frequency,
65      const WebRtc_UWord8 channels,
66      const WebRtc_UWord32 rate);
67
68  WebRtc_Word32 InvokeOnInitializeDecoder(
69      RtpFeedback* callback,
70      const WebRtc_Word32 id,
71      const WebRtc_Word8 payloadType,
72      const char payloadName[RTP_PAYLOAD_NAME_SIZE],
73      const ModuleRTPUtility::PayloadUnion& specificPayload) const;
74
75  virtual WebRtc_Word32 ReceiveRecoveredPacketCallback(
76      WebRtcRTPHeader* rtpHeader,
77      const WebRtc_UWord8* payloadData,
78      const WebRtc_UWord16 payloadDataLength);
79
80  void SetPacketOverHead(WebRtc_UWord16 packetOverHead);
81
82 protected:
83  WebRtc_Word32 SetCodecType(const RtpVideoCodecTypes videoType,
84                             WebRtcRTPHeader* rtpHeader) const;
85
86  WebRtc_Word32 ParseVideoCodecSpecificSwitch(
87      WebRtcRTPHeader* rtpHeader,
88      const WebRtc_UWord8* payloadData,
89      const WebRtc_UWord16 payloadDataLength,
90      const RtpVideoCodecTypes videoType,
91      const bool isFirstPacket);
92
93  WebRtc_Word32 ReceiveGenericCodec(WebRtcRTPHeader *rtpHeader,
94                                    const WebRtc_UWord8* payloadData,
95                                    const WebRtc_UWord16 payloadDataLength);
96
97  WebRtc_Word32 ReceiveVp8Codec(WebRtcRTPHeader *rtpHeader,
98                                const WebRtc_UWord8* payloadData,
99                                const WebRtc_UWord16 payloadDataLength);
100
101  WebRtc_Word32 BuildRTPheader(const WebRtcRTPHeader* rtpHeader,
102                               WebRtc_UWord8* dataBuffer) const;
103
104 private:
105  WebRtc_Word32 ParseVideoCodecSpecific(
106      WebRtcRTPHeader* rtpHeader,
107      const WebRtc_UWord8* payloadData,
108      const WebRtc_UWord16 payloadDataLength,
109      const RtpVideoCodecTypes videoType,
110      const bool isRED,
111      const WebRtc_UWord8* incomingRtpPacket,
112      const WebRtc_UWord16 incomingRtpPacketSize,
113      const WebRtc_Word64 nowMS,
114      const bool isFirstPacket);
115
116  WebRtc_Word32             _id;
117  const RTPPayloadRegistry* _rtpRtpPayloadRegistry;
118
119  CriticalSectionWrapper*   _criticalSectionReceiverVideo;
120
121  // FEC
122  bool                      _currentFecFrameDecoded;
123  ReceiverFEC*              _receiveFEC;
124};
125} // namespace webrtc
126#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_VIDEO_H_
127