webrtc_m130/webrtc/media/engine/scopedvideoencoder.h
magjed 3f89758398 Clean up ownership of webrtc::VideoEncoder
Currently, webrtc::VideoEncoders are supposed to be deleted through the
factory that created them with the
WebRtcVideoEncoderFactory::DestroyVideoEncoder method. In practice,
we sometimes use this method and sometimes we just call delete on the
webrtc::VideoEncoder pointer. We want to be able to consistently use the
normal destructor of webrtc::VideoEncoder instead of having to call
DestroyVideoEncoder so that we can put webrtc::VideoEncoder inside
an std::unique_ptr and make ownership more clear. As part of webrtc:7925
we also want to make a new encoder factory class that does not have the
DestroyVideoEncoder() method, and this CL is a step in that direction.

This CL introduces a helper function CreateScopedVideoEncoder that takes
a webrtc::VideoEncoder and a WebRtcVideoEncoderFactory pointer, and
returns a new webrtc::VideoEncoder instance that can be deleted through
the regular destructor.

This CL also removes WebRtcSimulcastEncoderFactory that almost only
contains logic for handling the DestroyVideoEncoder calls that we no
longer need, and inlines the rest of the logic inside the
WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoder method.

BUG=webrtc:7925

Review-Url: https://codereview.webrtc.org/3007643002
Cr-Commit-Position: refs/heads/master@{#19564}
2017-08-28 15:05:42 +00:00

34 lines
1.2 KiB
C++

/*
* Copyright (c) 2017 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_MEDIA_ENGINE_SCOPEDVIDEOENCODER_H_
#define WEBRTC_MEDIA_ENGINE_SCOPEDVIDEOENCODER_H_
#include <memory>
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
namespace cricket {
// Helper function that creates a webrtc::VideoEncoder held by an
// std::unique_ptr instead of having to be deleted through
// WebRtcVideoEncoderFactory::DestroyVideoEncoder. The factory passed in must
// outlive the returned encoder.
// TODO(magjed): This helper function will be deleted once
// cricket::WebRtcVideoEncoderFactory is deprecated, see
// https://bugs.chromium.org/p/webrtc/issues/detail?id=7925 for more info.
std::unique_ptr<webrtc::VideoEncoder> CreateScopedVideoEncoder(
cricket::WebRtcVideoEncoderFactory* factory,
const VideoCodec& codec);
} // namespace cricket
#endif // WEBRTC_MEDIA_ENGINE_SCOPEDVIDEOENCODER_H_