15976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org/*
25976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * libjingle
35976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Copyright 2011 Google Inc.
45976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *
55976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Redistribution and use in source and binary forms, with or without
65976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * modification, are permitted provided that the following conditions are met:
75976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *
85976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
95976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     this list of conditions and the following disclaimer.
105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     this list of conditions and the following disclaimer in the documentation
125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     and/or other materials provided with the distribution.
135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *  3. The name of the author may not be used to endorse or promote products
145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     derived from this software without specific prior written permission.
155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *
165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org */
275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#ifndef TALK_MEDIA_BASE_RTPUTILS_H_
295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#define TALK_MEDIA_BASE_RTPUTILS_H_
305976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
315976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/base/byteorder.h"
325976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
335976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgnamespace cricket {
345976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
355976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgconst size_t kMinRtpPacketLen = 12;
365976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgconst size_t kMaxRtpPacketLen = 2048;
375976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgconst size_t kMinRtcpPacketLen = 4;
385976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
395976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgstruct RtpHeader {
405976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  int payload_type;
415976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  int seq_num;
425976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  uint32 timestamp;
435976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  uint32 ssrc;
445976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org};
455976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
465976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgenum RtcpTypes {
475976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypeSR = 200,      // Sender report payload type.
485976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypeRR = 201,      // Receiver report payload type.
495976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypeSDES = 202,    // SDES payload type.
505976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypeBye = 203,     // BYE payload type.
515976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypeApp = 204,     // APP payload type.
525976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypeRTPFB = 205,   // Transport layer Feedback message payload type.
535976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  kRtcpTypePSFB = 206,    // Payload-specific Feedback message payload type.
545976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org};
555976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
565976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpVersion(const void* data, size_t len, int* version);
575976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpPayloadType(const void* data, size_t len, int* value);
585976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpSeqNum(const void* data, size_t len, int* value);
595976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpTimestamp(const void* data, size_t len, uint32* value);
605976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpSsrc(const void* data, size_t len, uint32* value);
615976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpHeaderLen(const void* data, size_t len, size_t* value);
625976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtcpType(const void* data, size_t len, int* value);
635976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtcpSsrc(const void* data, size_t len, uint32* value);
645976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool GetRtpHeader(const void* data, size_t len, RtpHeader* header);
655976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
665976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Assumes marker bit is 0.
675976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool SetRtpHeaderFlags(
685976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org    void* data, size_t len,
695976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org    bool padding, bool extension, int csrc_count);
705976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool SetRtpPayloadType(void* data, size_t len, int value);
715976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool SetRtpSeqNum(void* data, size_t len, int value);
725976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool SetRtpTimestamp(void* data, size_t len, uint32 value);
735976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool SetRtpSsrc(void* data, size_t len, uint32 value);
745976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Assumes version 2, no padding, no extensions, no csrcs.
755976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool SetRtpHeader(void* data, size_t len, const RtpHeader& header);
765976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
775976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}  // namespace cricket
785976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
795976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#endif  // TALK_MEDIA_BASE_RTPUTILS_H_
80