#ifndef CONTENT_RENDERER_MEDIA_VIDEO_SOURCE_HANDLER_H_
#define CONTENT_RENDERER_MEDIA_VIDEO_SOURCE_HANDLER_H_
#include <map>
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/content_export.h"
#include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h"
namespace cricket {
class VideoFrame;
}
namespace content {
class MediaStreamDependencyFactory;
class MediaStreamRegistryInterface;
class PpFrameReceiver;
class CONTENT_EXPORT FrameReaderInterface {
public:
virtual bool GotFrame(cricket::VideoFrame* frame) = 0;
protected:
virtual ~FrameReaderInterface() {}
};
class CONTENT_EXPORT VideoSourceHandler {
public:
explicit VideoSourceHandler(MediaStreamRegistryInterface* registry);
virtual ~VideoSourceHandler();
bool Open(const std::string& url, FrameReaderInterface* reader);
bool Close(FrameReaderInterface* reader);
cricket::VideoRenderer* GetReceiver(FrameReaderInterface* reader);
private:
struct SourceInfo {
SourceInfo(scoped_refptr<webrtc::VideoSourceInterface> source,
FrameReaderInterface* reader);
~SourceInfo();
scoped_ptr<PpFrameReceiver> receiver_;
scoped_refptr<webrtc::VideoSourceInterface> source_;
};
typedef std::map<FrameReaderInterface*, SourceInfo*> SourceInfoMap;
scoped_refptr<webrtc::VideoSourceInterface> GetFirstVideoSource(
const std::string& url);
MediaStreamRegistryInterface* registry_;
SourceInfoMap reader_to_receiver_;
DISALLOW_COPY_AND_ASSIGN(VideoSourceHandler);
};
}
#endif