| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 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 | 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 | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 
| 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 
| 13 | 13 | 
|  | 14 #include <stdio.h> | 
|  | 15 #include <vector> | 
|  | 16 | 
| 14 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 17 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 
| 15 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 18 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 
| 16 | 19 | 
| 17 #include <stdio.h> |  | 
| 18 |  | 
| 19 #include "webrtc/base/criticalsection.h" | 20 #include "webrtc/base/criticalsection.h" | 
| 20 #include "webrtc/base/scoped_ptr.h" | 21 #include "webrtc/base/scoped_ptr.h" | 
| 21 | 22 | 
| 22 namespace webrtc { | 23 namespace webrtc { | 
| 23 class CriticalSectionWrapper; | 24 class CriticalSectionWrapper; | 
| 24 | 25 | 
| 25 namespace media_optimization { | 26 namespace media_optimization { | 
| 26 class MediaOptimization; | 27 class MediaOptimization; | 
| 27 }  // namespace media_optimization | 28 }  // namespace media_optimization | 
| 28 | 29 | 
| 29 struct EncoderParameters { | 30 struct EncoderParameters { | 
| 30   uint32_t target_bitrate; | 31   uint32_t target_bitrate; | 
| 31   uint8_t loss_rate; | 32   uint8_t loss_rate; | 
| 32   int64_t rtt; | 33   int64_t rtt; | 
| 33   uint32_t input_frame_rate; | 34   uint32_t input_frame_rate; | 
| 34 }; | 35 }; | 
| 35 | 36 | 
| 36 /*************************************/ | 37 /*************************************/ | 
| 37 /* VCMEncodeFrameCallback class     */ | 38 /* VCMEncodeFrameCallback class     */ | 
| 38 /***********************************/ | 39 /***********************************/ | 
| 39 class VCMEncodedFrameCallback : public EncodedImageCallback | 40 class VCMEncodedFrameCallback : public EncodedImageCallback { | 
| 40 { | 41  public: | 
| 41 public: | 42     explicit VCMEncodedFrameCallback( | 
| 42     VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback); | 43       EncodedImageCallback* post_encode_callback); | 
| 43     virtual ~VCMEncodedFrameCallback(); | 44     virtual ~VCMEncodedFrameCallback(); | 
| 44 | 45 | 
| 45     /* | 46     /* | 
| 46     * Callback implementation - codec encode complete | 47     * Callback implementation - codec encode complete | 
| 47     */ | 48     */ | 
| 48     int32_t Encoded( | 49     int32_t Encoded( | 
| 49         const EncodedImage& encodedImage, | 50         const EncodedImage& encodedImage, | 
| 50         const CodecSpecificInfo* codecSpecificInfo = NULL, | 51         const CodecSpecificInfo* codecSpecificInfo = NULL, | 
| 51         const RTPFragmentationHeader* fragmentationHeader = NULL); | 52         const RTPFragmentationHeader* fragmentationHeader = NULL); | 
| 52     /* | 53     /* | 
| 53     * Callback implementation - generic encoder encode complete | 54     * Callback implementation - generic encoder encode complete | 
| 54     */ | 55     */ | 
| 55     int32_t SetTransportCallback(VCMPacketizationCallback* transport); | 56     int32_t SetTransportCallback(VCMPacketizationCallback* transport); | 
| 56     /** | 57     /** | 
| 57     * Set media Optimization | 58     * Set media Optimization | 
| 58     */ | 59     */ | 
| 59     void SetMediaOpt (media_optimization::MediaOptimization* mediaOpt); | 60     void SetMediaOpt(media_optimization::MediaOptimization* mediaOpt); | 
| 60 | 61 | 
| 61     void SetPayloadType(uint8_t payloadType) { _payloadType = payloadType; }; | 62     void SetPayloadType(uint8_t payloadType) { | 
| 62     void SetInternalSource(bool internalSource) { _internalSource = internalSour
     ce; }; | 63       _payloadType = payloadType; | 
|  | 64     } | 
|  | 65 | 
|  | 66     void SetInternalSource(bool internalSource) { | 
|  | 67       _internalSource = internalSource; | 
|  | 68     } | 
| 63 | 69 | 
| 64     void SetRotation(VideoRotation rotation) { _rotation = rotation; } | 70     void SetRotation(VideoRotation rotation) { _rotation = rotation; } | 
| 65     void SignalLastEncoderImplementationUsed( | 71     void SignalLastEncoderImplementationUsed( | 
| 66         const char* encoder_implementation_name); | 72         const char* encoder_implementation_name); | 
| 67 | 73 | 
| 68 private: | 74  private: | 
| 69     VCMPacketizationCallback* send_callback_; | 75     VCMPacketizationCallback* send_callback_; | 
| 70     media_optimization::MediaOptimization* _mediaOpt; | 76     media_optimization::MediaOptimization* _mediaOpt; | 
| 71     uint8_t _payloadType; | 77     uint8_t _payloadType; | 
| 72     bool _internalSource; | 78     bool _internalSource; | 
| 73     VideoRotation _rotation; | 79     VideoRotation _rotation; | 
| 74 | 80 | 
| 75     EncodedImageCallback* post_encode_callback_; | 81     EncodedImageCallback* post_encode_callback_; | 
| 76 | 82 | 
| 77 #ifdef DEBUG_ENCODER_BIT_STREAM | 83 #ifdef DEBUG_ENCODER_BIT_STREAM | 
| 78     FILE* _bitStreamAfterEncoder; | 84     FILE* _bitStreamAfterEncoder; | 
| 79 #endif | 85 #endif | 
| 80 };// end of VCMEncodeFrameCallback class | 86 };  // end of VCMEncodeFrameCallback class | 
| 81 |  | 
| 82 | 87 | 
| 83 /******************************/ | 88 /******************************/ | 
| 84 /* VCMGenericEncoder class    */ | 89 /* VCMGenericEncoder class    */ | 
| 85 /******************************/ | 90 /******************************/ | 
| 86 class VCMGenericEncoder | 91 class VCMGenericEncoder { | 
| 87 { | 92   friend class VCMCodecDataBase; | 
| 88     friend class VCMCodecDataBase; |  | 
| 89 public: |  | 
| 90     VCMGenericEncoder(VideoEncoder* encoder, |  | 
| 91                       VideoEncoderRateObserver* rate_observer, |  | 
| 92                       VCMEncodedFrameCallback* encoded_frame_callback, |  | 
| 93                       bool internalSource); |  | 
| 94     ~VCMGenericEncoder(); |  | 
| 95     /** |  | 
| 96     * Free encoder memory |  | 
| 97     */ |  | 
| 98     int32_t Release(); |  | 
| 99     /** |  | 
| 100     * Initialize the encoder with the information from the VideoCodec |  | 
| 101     */ |  | 
| 102     int32_t InitEncode(const VideoCodec* settings, |  | 
| 103                        int32_t numberOfCores, |  | 
| 104                        size_t maxPayloadSize); |  | 
| 105     /** |  | 
| 106     * Encode raw image |  | 
| 107     * inputFrame        : Frame containing raw image |  | 
| 108     * codecSpecificInfo : Specific codec data |  | 
| 109     * cameraFrameRate   : Request or information from the remote side |  | 
| 110     * frameType         : The requested frame type to encode |  | 
| 111     */ |  | 
| 112     int32_t Encode(const VideoFrame& inputFrame, |  | 
| 113                    const CodecSpecificInfo* codecSpecificInfo, |  | 
| 114                    const std::vector<FrameType>& frameTypes); |  | 
| 115 | 93 | 
| 116     void SetEncoderParameters(const EncoderParameters& params); | 94  public: | 
| 117     EncoderParameters GetEncoderParameters() const; | 95   VCMGenericEncoder(VideoEncoder* encoder, | 
|  | 96                     VideoEncoderRateObserver* rate_observer, | 
|  | 97                     VCMEncodedFrameCallback* encoded_frame_callback, | 
|  | 98                     bool internalSource); | 
|  | 99   ~VCMGenericEncoder(); | 
|  | 100   /** | 
|  | 101   * Free encoder memory | 
|  | 102   */ | 
|  | 103   int32_t Release(); | 
|  | 104   /** | 
|  | 105   * Initialize the encoder with the information from the VideoCodec | 
|  | 106   */ | 
|  | 107   int32_t InitEncode(const VideoCodec* settings, | 
|  | 108                      int32_t numberOfCores, | 
|  | 109                      size_t maxPayloadSize); | 
|  | 110   /** | 
|  | 111   * Encode raw image | 
|  | 112   * inputFrame        : Frame containing raw image | 
|  | 113   * codecSpecificInfo : Specific codec data | 
|  | 114   * cameraFrameRate   : Request or information from the remote side | 
|  | 115   * frameType         : The requested frame type to encode | 
|  | 116   */ | 
|  | 117   int32_t Encode(const VideoFrame& inputFrame, | 
|  | 118                  const CodecSpecificInfo* codecSpecificInfo, | 
|  | 119                  const std::vector<FrameType>& frameTypes); | 
| 118 | 120 | 
| 119     int32_t SetPeriodicKeyFrames(bool enable); | 121   void SetEncoderParameters(const EncoderParameters& params); | 
|  | 122   EncoderParameters GetEncoderParameters() const; | 
| 120 | 123 | 
| 121     int32_t RequestFrame(const std::vector<FrameType>& frame_types); | 124   int32_t SetPeriodicKeyFrames(bool enable); | 
| 122 | 125 | 
| 123     bool InternalSource() const; | 126   int32_t RequestFrame(const std::vector<FrameType>& frame_types); | 
| 124 | 127 | 
| 125     void OnDroppedFrame(); | 128   bool InternalSource() const; | 
| 126 | 129 | 
| 127     bool SupportsNativeHandle() const; | 130   void OnDroppedFrame(); | 
| 128 | 131 | 
| 129     int GetTargetFramerate(); | 132   bool SupportsNativeHandle() const; | 
| 130 | 133 | 
| 131 private: | 134   int GetTargetFramerate(); | 
| 132     VideoEncoder* const encoder_; | 135 | 
| 133     VideoEncoderRateObserver* const rate_observer_; | 136  private: | 
| 134     VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; | 137   VideoEncoder* const encoder_; | 
| 135     const bool internal_source_; | 138   VideoEncoderRateObserver* const rate_observer_; | 
| 136     mutable rtc::CriticalSection params_lock_; | 139   VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; | 
| 137     EncoderParameters encoder_params_ GUARDED_BY(params_lock_); | 140   const bool internal_source_; | 
| 138     VideoRotation rotation_; | 141   mutable rtc::CriticalSection params_lock_; | 
| 139     bool is_screenshare_; | 142   EncoderParameters encoder_params_ GUARDED_BY(params_lock_); | 
| 140 }; // end of VCMGenericEncoder class | 143   VideoRotation rotation_; | 
|  | 144   bool is_screenshare_; | 
|  | 145 };  // end of VCMGenericEncoder class | 
| 141 | 146 | 
| 142 }  // namespace webrtc | 147 }  // namespace webrtc | 
| 143 | 148 | 
| 144 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 149 #endif  // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 
| OLD | NEW | 
|---|