1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/signaling/src/media-conduit/CodecConfig.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,128 @@ 1.4 + 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef CODEC_CONFIG_H_ 1.10 +#define CODEC_CONFIG_H_ 1.11 + 1.12 +#include <string> 1.13 +#include "ccsdp_rtcp_fb.h" 1.14 + 1.15 +namespace mozilla { 1.16 + 1.17 +class LoadManager; 1.18 + 1.19 +/** 1.20 + * Minimalistic Audio Codec Config Params 1.21 + */ 1.22 +struct AudioCodecConfig 1.23 +{ 1.24 + /* 1.25 + * The data-types for these properties mimic the 1.26 + * corresponding webrtc::CodecInst data-types. 1.27 + */ 1.28 + int mType; 1.29 + std::string mName; 1.30 + int mFreq; 1.31 + int mPacSize; 1.32 + int mChannels; 1.33 + int mRate; 1.34 + LoadManager* mLoadManager; 1.35 + 1.36 + /* Default constructor is not provided since as a consumer, we 1.37 + * can't decide the default configuration for the codec 1.38 + */ 1.39 + explicit AudioCodecConfig(int type, std::string name, 1.40 + int freq,int pacSize, 1.41 + int channels, int rate, 1.42 + LoadManager* load_manager = nullptr) 1.43 + : mType(type), 1.44 + mName(name), 1.45 + mFreq(freq), 1.46 + mPacSize(pacSize), 1.47 + mChannels(channels), 1.48 + mRate(rate), 1.49 + mLoadManager(load_manager) 1.50 + 1.51 + { 1.52 + } 1.53 +}; 1.54 + 1.55 +/* 1.56 + * Minimalisitc video codec configuration 1.57 + * More to be added later depending on the use-case 1.58 + */ 1.59 + 1.60 +struct VideoCodecConfig 1.61 +{ 1.62 + /* 1.63 + * The data-types for these properties mimic the 1.64 + * corresponding webrtc::VideoCodec data-types. 1.65 + */ 1.66 + int mType; 1.67 + std::string mName; 1.68 + uint32_t mRtcpFbTypes; 1.69 + unsigned int mMaxFrameSize; 1.70 + unsigned int mMaxFrameRate; 1.71 + LoadManager* mLoadManager; 1.72 + 1.73 + VideoCodecConfig(int type, 1.74 + std::string name, 1.75 + int rtcpFbTypes, 1.76 + LoadManager* load_manager = nullptr) : 1.77 + mType(type), 1.78 + mName(name), 1.79 + mRtcpFbTypes(rtcpFbTypes), 1.80 + mMaxFrameSize(0), 1.81 + mMaxFrameRate(0), 1.82 + mLoadManager(load_manager) 1.83 + { 1.84 + // Replace codec name here because WebRTC.org code has a whitelist of 1.85 + // supported video codec in |webrtc::ViECodecImpl::CodecValid()| and will 1.86 + // reject registration of those not in it. 1.87 + // TODO: bug 995884 to support H.264 in WebRTC.org code. 1.88 + if (mName == "H264_P0") 1.89 + mName = "I420"; 1.90 + } 1.91 + 1.92 + VideoCodecConfig(int type, 1.93 + std::string name, 1.94 + int rtcpFbTypes, 1.95 + unsigned int max_fs, 1.96 + unsigned int max_fr, 1.97 + LoadManager* load_manager = nullptr) : 1.98 + mType(type), 1.99 + mName(name), 1.100 + mRtcpFbTypes(rtcpFbTypes), 1.101 + mMaxFrameSize(max_fs), 1.102 + mMaxFrameRate(max_fr), 1.103 + mLoadManager(load_manager) 1.104 + { 1.105 + // Replace codec name here because WebRTC.org code has a whitelist of 1.106 + // supported video codec in |webrtc::ViECodecImpl::CodecValid()| and will 1.107 + // reject registration of those not in it. 1.108 + // TODO: bug 995884 to support H.264 in WebRTC.org code. 1.109 + if (mName == "H264_P0") 1.110 + mName = "I420"; 1.111 + } 1.112 + 1.113 + 1.114 + bool RtcpFbIsSet(sdp_rtcp_fb_nack_type_e type) const 1.115 + { 1.116 + return mRtcpFbTypes & sdp_rtcp_fb_nack_to_bitmap(type); 1.117 + } 1.118 + 1.119 + bool RtcpFbIsSet(sdp_rtcp_fb_ack_type_e type) const 1.120 + { 1.121 + return mRtcpFbTypes & sdp_rtcp_fb_ack_to_bitmap(type); 1.122 + } 1.123 + 1.124 + bool RtcpFbIsSet(sdp_rtcp_fb_ccm_type_e type) const 1.125 + { 1.126 + return mRtcpFbTypes & sdp_rtcp_fb_ccm_to_bitmap(type); 1.127 + } 1.128 + 1.129 +}; 1.130 +} 1.131 +#endif