2015-06-29 14:34:58 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2911053002/ )
Reason for revert:
Take three of relanding this after all internal issues have been resolved.
Original issue's description:
> Revert of Split iOS sdk in to separate targets (patchset #3 id:320001 of https://codereview.webrtc.org/2893843003/ )
>
> Reason for revert:
> Breaks downstream project.
>
> Original issue's description:
> > Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2893593002/ )
> >
> > Reason for revert:
> > Take two of fixing downstream issues?
> >
> > Original issue's description:
> > > Revert of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2890733003/ )
> > >
> > > Reason for revert:
> > > Still problems with downstream projects
> > >
> > > Original issue's description:
> > > > Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2890513002/ )
> > > >
> > > > Reason for revert:
> > > > Fixing downstream breakages
> > > >
> > > > Original issue's description:
> > > > > Revert of Split iOS sdk in to separate targets (patchset #13 id:280001 of https://codereview.webrtc.org/2862543002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Breaking downstream projects.
> > > > >
> > > > > Original issue's description:
> > > > > > Split iOS sdk in to separate targets
> > > > > >
> > > > > > This CL splits the iOS sdk into separate static libraries for video,
> > > > > > audio, ui, common, and peerconnection-related code. This will in the
> > > > > > future make it easier to compile WebRTC without unneeded components.
> > > > > >
> > > > > > BUG=webrtc:4867
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2862543002
> > > > > > Cr-Commit-Position: refs/heads/master@{#18166}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/52c83fe7102f566cf35a7533092873d58b38f426
> > > > >
> > > > > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,kthelgason@webrtc.org
> > > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > > NOPRESUBMIT=true
> > > > > NOTREECHECKS=true
> > > > > NOTRY=true
> > > > > BUG=webrtc:4867
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2890513002
> > > > > Cr-Commit-Position: refs/heads/master@{#18170}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/9756238084707787f735e1294e896e462e459717
> > > >
> > > > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:4867
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2890733003
> > > > Cr-Commit-Position: refs/heads/master@{#18174}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/d51e042492bedd057bc0cac7828979d5c7369cea
> > >
> > > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4867
> > >
> > > Review-Url: https://codereview.webrtc.org/2893593002
> > > Cr-Commit-Position: refs/heads/master@{#18182}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/37144b214e2baf62ecb262ab878dde8c59cdd6a3
> >
> > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:4867
> >
> > Review-Url: https://codereview.webrtc.org/2893843003
> > Cr-Commit-Position: refs/heads/master@{#18303}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/580c3522d294c877adfe555048c675bd8d166657
>
> TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org,kthelgason@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4867
>
> Review-Url: https://codereview.webrtc.org/2911053002
> Cr-Commit-Position: refs/heads/master@{#18309}
> Committed: https://chromium.googlesource.com/external/webrtc/+/af5c05540cc8208f682cafe88c5c16a505479196
TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org,mbonadei@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4867
Review-Url: https://codereview.webrtc.org/2913753003
Cr-Commit-Position: refs/heads/master@{#18319}
2017-05-30 01:48:47 -07:00
|
|
|
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_VIDEOTOOLBOX_ENCODER_H_
|
|
|
|
|
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_VIDEOTOOLBOX_ENCODER_H_
|
2015-06-29 14:34:58 -07:00
|
|
|
|
2017-01-10 07:44:26 -08:00
|
|
|
#include "webrtc/api/video/video_rotation.h"
|
2016-05-24 12:21:58 +02:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2016-10-26 02:48:16 -07:00
|
|
|
#include "webrtc/common_video/h264/h264_bitstream_parser.h"
|
2016-04-26 12:55:07 -07:00
|
|
|
#include "webrtc/common_video/include/bitrate_adjuster.h"
|
2016-11-15 09:56:55 -08:00
|
|
|
#include "webrtc/media/base/codec.h"
|
2015-06-29 14:34:58 -07:00
|
|
|
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
2016-05-24 12:21:58 +02:00
|
|
|
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
2015-06-29 14:34:58 -07:00
|
|
|
|
|
|
|
|
#include <VideoToolbox/VideoToolbox.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
// This file provides a H264 encoder implementation using the VideoToolbox
|
|
|
|
|
// APIs. Since documentation is almost non-existent, this is largely based on
|
|
|
|
|
// the information in the VideoToolbox header files, a talk from WWDC 2014 and
|
|
|
|
|
// experimentation.
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class H264VideoToolboxEncoder : public H264Encoder {
|
|
|
|
|
public:
|
2016-11-15 09:56:55 -08:00
|
|
|
explicit H264VideoToolboxEncoder(const cricket::VideoCodec& codec);
|
2015-06-29 14:34:58 -07:00
|
|
|
|
|
|
|
|
~H264VideoToolboxEncoder() override;
|
|
|
|
|
|
|
|
|
|
int InitEncode(const VideoCodec* codec_settings,
|
|
|
|
|
int number_of_cores,
|
|
|
|
|
size_t max_payload_size) override;
|
|
|
|
|
|
|
|
|
|
int Encode(const VideoFrame& input_image,
|
|
|
|
|
const CodecSpecificInfo* codec_specific_info,
|
2015-10-19 02:39:06 -07:00
|
|
|
const std::vector<FrameType>* frame_types) override;
|
2015-06-29 14:34:58 -07:00
|
|
|
|
|
|
|
|
int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override;
|
|
|
|
|
|
|
|
|
|
int SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
|
|
|
|
|
|
|
|
|
|
int SetRates(uint32_t new_bitrate_kbit, uint32_t frame_rate) override;
|
|
|
|
|
|
|
|
|
|
int Release() override;
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
const char* ImplementationName() const override;
|
|
|
|
|
|
2016-07-12 01:26:42 -07:00
|
|
|
bool SupportsNativeHandle() const override;
|
|
|
|
|
|
2016-02-23 22:49:42 -08:00
|
|
|
void OnEncodedFrame(OSStatus status,
|
|
|
|
|
VTEncodeInfoFlags info_flags,
|
|
|
|
|
CMSampleBufferRef sample_buffer,
|
|
|
|
|
CodecSpecificInfo codec_specific_info,
|
|
|
|
|
int32_t width,
|
|
|
|
|
int32_t height,
|
|
|
|
|
int64_t render_time_ms,
|
2016-04-19 15:01:23 +02:00
|
|
|
uint32_t timestamp,
|
|
|
|
|
VideoRotation rotation);
|
2016-02-23 22:49:42 -08:00
|
|
|
|
2016-11-29 01:44:11 -08:00
|
|
|
ScalingSettings GetScalingSettings() const override;
|
|
|
|
|
|
2015-06-29 14:34:58 -07:00
|
|
|
private:
|
|
|
|
|
int ResetCompressionSession();
|
|
|
|
|
void ConfigureCompressionSession();
|
|
|
|
|
void DestroyCompressionSession();
|
2016-06-13 13:06:01 +02:00
|
|
|
rtc::scoped_refptr<VideoFrameBuffer> GetScaledBufferOnEncode(
|
|
|
|
|
const rtc::scoped_refptr<VideoFrameBuffer>& frame);
|
2016-02-23 22:49:42 -08:00
|
|
|
void SetBitrateBps(uint32_t bitrate_bps);
|
|
|
|
|
void SetEncoderBitrateBps(uint32_t bitrate_bps);
|
2015-06-29 14:34:58 -07:00
|
|
|
|
2016-02-23 22:49:42 -08:00
|
|
|
EncodedImageCallback* callback_;
|
2015-06-29 14:34:58 -07:00
|
|
|
VTCompressionSessionRef compression_session_;
|
2016-02-23 22:49:42 -08:00
|
|
|
BitrateAdjuster bitrate_adjuster_;
|
2016-12-16 02:10:20 -08:00
|
|
|
H264PacketizationMode packetization_mode_;
|
2016-02-23 22:49:42 -08:00
|
|
|
uint32_t target_bitrate_bps_;
|
|
|
|
|
uint32_t encoder_bitrate_bps_;
|
2015-06-29 14:34:58 -07:00
|
|
|
int32_t width_;
|
|
|
|
|
int32_t height_;
|
2017-04-11 10:34:31 -07:00
|
|
|
VideoCodecMode mode_;
|
2016-11-15 09:56:55 -08:00
|
|
|
const CFStringRef profile_;
|
2016-05-24 12:21:58 +02:00
|
|
|
|
|
|
|
|
H264BitstreamParser h264_bitstream_parser_;
|
2016-10-20 03:34:29 -07:00
|
|
|
std::vector<uint8_t> nv12_scale_buffer_;
|
2015-06-29 14:34:58 -07:00
|
|
|
}; // H264VideoToolboxEncoder
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2911053002/ )
Reason for revert:
Take three of relanding this after all internal issues have been resolved.
Original issue's description:
> Revert of Split iOS sdk in to separate targets (patchset #3 id:320001 of https://codereview.webrtc.org/2893843003/ )
>
> Reason for revert:
> Breaks downstream project.
>
> Original issue's description:
> > Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2893593002/ )
> >
> > Reason for revert:
> > Take two of fixing downstream issues?
> >
> > Original issue's description:
> > > Revert of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2890733003/ )
> > >
> > > Reason for revert:
> > > Still problems with downstream projects
> > >
> > > Original issue's description:
> > > > Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2890513002/ )
> > > >
> > > > Reason for revert:
> > > > Fixing downstream breakages
> > > >
> > > > Original issue's description:
> > > > > Revert of Split iOS sdk in to separate targets (patchset #13 id:280001 of https://codereview.webrtc.org/2862543002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Breaking downstream projects.
> > > > >
> > > > > Original issue's description:
> > > > > > Split iOS sdk in to separate targets
> > > > > >
> > > > > > This CL splits the iOS sdk into separate static libraries for video,
> > > > > > audio, ui, common, and peerconnection-related code. This will in the
> > > > > > future make it easier to compile WebRTC without unneeded components.
> > > > > >
> > > > > > BUG=webrtc:4867
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2862543002
> > > > > > Cr-Commit-Position: refs/heads/master@{#18166}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/52c83fe7102f566cf35a7533092873d58b38f426
> > > > >
> > > > > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,kthelgason@webrtc.org
> > > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > > NOPRESUBMIT=true
> > > > > NOTREECHECKS=true
> > > > > NOTRY=true
> > > > > BUG=webrtc:4867
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2890513002
> > > > > Cr-Commit-Position: refs/heads/master@{#18170}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/9756238084707787f735e1294e896e462e459717
> > > >
> > > > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:4867
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2890733003
> > > > Cr-Commit-Position: refs/heads/master@{#18174}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/d51e042492bedd057bc0cac7828979d5c7369cea
> > >
> > > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:4867
> > >
> > > Review-Url: https://codereview.webrtc.org/2893593002
> > > Cr-Commit-Position: refs/heads/master@{#18182}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/37144b214e2baf62ecb262ab878dde8c59cdd6a3
> >
> > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:4867
> >
> > Review-Url: https://codereview.webrtc.org/2893843003
> > Cr-Commit-Position: refs/heads/master@{#18303}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/580c3522d294c877adfe555048c675bd8d166657
>
> TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org,kthelgason@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4867
>
> Review-Url: https://codereview.webrtc.org/2911053002
> Cr-Commit-Position: refs/heads/master@{#18309}
> Committed: https://chromium.googlesource.com/external/webrtc/+/af5c05540cc8208f682cafe88c5c16a505479196
TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org,mbonadei@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4867
Review-Url: https://codereview.webrtc.org/2913753003
Cr-Commit-Position: refs/heads/master@{#18319}
2017-05-30 01:48:47 -07:00
|
|
|
#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_VIDEOTOOLBOX_ENCODER_H_
|