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_UTILITY_SOURCE_VIDEO_CODER_H_ 12 #define WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_CODER_H_ 13 14 #ifdef WEBRTC_MODULE_UTILITY_VIDEO 15 16 #include "webrtc/engine_configurations.h" 17 #include "webrtc/modules/video_coding/main/interface/video_coding.h" 18 19 namespace webrtc { 20 class VideoCoder : public VCMPacketizationCallback, public VCMReceiveCallback 21 { 22 public: 23 VideoCoder(); 24 ~VideoCoder(); 25 26 int32_t SetEncodeCodec(VideoCodec& videoCodecInst, 27 uint32_t numberOfCores, 28 uint32_t maxPayloadSize); 29 30 31 // Select the codec that should be used for decoding. videoCodecInst.plType 32 // will be set to the codec's default payload type. 33 int32_t SetDecodeCodec(VideoCodec& videoCodecInst, int32_t numberOfCores); 34 35 int32_t Decode(I420VideoFrame& decodedVideo, 36 const EncodedVideoData& encodedData); 37 38 int32_t Encode(const I420VideoFrame& videoFrame, 39 EncodedVideoData& videoEncodedData); 40 41 int8_t DefaultPayloadType(const char* plName); 42 43 private: 44 // VCMReceiveCallback function. 45 // Note: called by VideoCodingModule when decoding finished. 46 virtual int32_t FrameToRender(I420VideoFrame& videoFrame) OVERRIDE; 47 48 // VCMPacketizationCallback function. 49 // Note: called by VideoCodingModule when encoding finished. 50 virtual int32_t SendData( 51 FrameType /*frameType*/, 52 uint8_t /*payloadType*/, 53 uint32_t /*timeStamp*/, 54 int64_t capture_time_ms, 55 const uint8_t* payloadData, 56 uint32_t payloadSize, 57 const RTPFragmentationHeader& /* fragmentationHeader*/, 58 const RTPVideoHeader* rtpTypeHdr) OVERRIDE; 59 60 VideoCodingModule* _vcm; 61 I420VideoFrame* _decodedVideo; 62 EncodedVideoData* _videoEncodedData; 63 }; 64 } // namespace webrtc 65 #endif // WEBRTC_MODULE_UTILITY_VIDEO 66 #endif // WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_CODER_H_ 67