1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
#define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
#include <stdio.h>
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
namespace webrtc {
class CriticalSectionWrapper;
namespace media_optimization {
class MediaOptimization;
} // namespace media_optimization
/*************************************/
/* VCMEncodeFrameCallback class */
/***********************************/
class VCMEncodedFrameCallback : public EncodedImageCallback
{
public:
VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback);
virtual ~VCMEncodedFrameCallback();
/*
* Callback implementation - codec encode complete
*/
int32_t Encoded(
const EncodedImage& encodedImage,
const CodecSpecificInfo* codecSpecificInfo = NULL,
const RTPFragmentationHeader* fragmentationHeader = NULL);
/*
* Callback implementation - generic encoder encode complete
*/
int32_t SetTransportCallback(VCMPacketizationCallback* transport);
/**
* Set media Optimization
*/
void SetMediaOpt (media_optimization::MediaOptimization* mediaOpt);
void SetPayloadType(uint8_t payloadType) { _payloadType = payloadType; };
void SetInternalSource(bool internalSource) { _internalSource = internalSource; };
private:
VCMPacketizationCallback* _sendCallback;
media_optimization::MediaOptimization* _mediaOpt;
uint8_t _payloadType;
bool _internalSource;
EncodedImageCallback* post_encode_callback_;
#ifdef DEBUG_ENCODER_BIT_STREAM
FILE* _bitStreamAfterEncoder;
#endif
};// end of VCMEncodeFrameCallback class
/******************************/
/* VCMGenericEncoder class */
/******************************/
class VCMGenericEncoder
{
friend class VCMCodecDataBase;
public:
VCMGenericEncoder(VideoEncoder& encoder, bool internalSource = false);
~VCMGenericEncoder();
/**
* Free encoder memory
*/
int32_t Release();
/**
* Initialize the encoder with the information from the VideoCodec
*/
int32_t InitEncode(const VideoCodec* settings,
int32_t numberOfCores,
size_t maxPayloadSize);
/**
* Encode raw image
* inputFrame : Frame containing raw image
* codecSpecificInfo : Specific codec data
* cameraFrameRate : Request or information from the remote side
* frameType : The requested frame type to encode
*/
int32_t Encode(const I420VideoFrame& inputFrame,
const CodecSpecificInfo* codecSpecificInfo,
const std::vector<FrameType>& frameTypes);
/**
* Set new target bitrate (bits/s) and framerate.
* Return Value: new bit rate if OK, otherwise <0s.
*/
int32_t SetRates(uint32_t target_bitrate, uint32_t frameRate);
/**
* Set a new packet loss rate and a new round-trip time in milliseconds.
*/
int32_t SetChannelParameters(int32_t packetLoss, int rtt);
int32_t CodecConfigParameters(uint8_t* buffer, int32_t size);
/**
* Register a transport callback which will be called to deliver the encoded
* buffers
*/
int32_t RegisterEncodeCallback(
VCMEncodedFrameCallback* VCMencodedFrameCallback);
/**
* Get encoder bit rate
*/
uint32_t BitRate() const;
/**
* Get encoder frame rate
*/
uint32_t FrameRate() const;
int32_t SetPeriodicKeyFrames(bool enable);
int32_t RequestFrame(const std::vector<FrameType>& frame_types);
bool InternalSource() const;
private:
VideoEncoder& _encoder;
VideoCodecType _codecType;
VCMEncodedFrameCallback* _VCMencodedFrameCallback;
uint32_t _bitRate;
uint32_t _frameRate;
bool _internalSource;
}; // end of VCMGenericEncoder class
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
|