Files
platform-external-webrtc/webrtc/api/videotrackrenderers.h
nisse db25d2e8c5 Make VideoTrack and VideoTrackRenderers implement rtc::VideoSourceInterface.
This patch tries to only change the interface to VideoTrack, with
minimal changes to the implementation. Some points worth noting:

VideoTrackRenderers should ultimately be deleted, but it is kept for
now since we need an object implementing webrtc::VideoRenderer, and
that shouldn't be VideoTrack.

BUG=webrtc:5426
TBR=glaznev@webrtc.org  // please look at  examples

Review URL: https://codereview.webrtc.org/1684423002

Cr-Commit-Position: refs/heads/master@{#11775}
2016-02-26 09:25:02 +00:00

57 lines
2.0 KiB
C++

/*
* Copyright 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_API_VIDEOTRACKRENDERERS_H_
#define WEBRTC_API_VIDEOTRACKRENDERERS_H_
#include <set>
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/media/base/videorenderer.h"
namespace webrtc {
// Class used for rendering cricket::VideoFrames to multiple renderers of type
// VideoRendererInterface.
// Each VideoTrack owns a VideoTrackRenderers instance.
// The class is thread safe. Rendering to the added VideoRendererInterfaces is
// done on the same thread as the cricket::VideoRenderer.
class VideoTrackRenderers
: public cricket::VideoRenderer,
public rtc::VideoSourceInterface<cricket::VideoFrame> {
public:
VideoTrackRenderers();
~VideoTrackRenderers();
// Implements cricket::VideoRenderer. If the track is disabled,
// incoming frames are replaced by black frames.
virtual bool RenderFrame(const cricket::VideoFrame* frame);
void AddOrUpdateSink(VideoSinkInterface<cricket::VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override;
void RemoveSink(VideoSinkInterface<cricket::VideoFrame>* sink) override;
void SetEnabled(bool enable);
private:
// Pass the frame on to to each registered renderer. Requires
// critical_section_ already locked.
void RenderFrameToSinks(const cricket::VideoFrame& frame);
bool enabled_;
std::vector<VideoSinkInterface<cricket::VideoFrame>*> sinks_;
rtc::CriticalSection critical_section_; // Protects the above variables
};
} // namespace webrtc
#endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_