#ifndef MediaStreamDescriptor_h
#define MediaStreamDescriptor_h
#include "platform/mediastream/MediaStreamComponent.h"
#include "platform/mediastream/MediaStreamSource.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/Vector.h"
namespace WebCore {
class MediaStreamDescriptorClient {
public:
virtual ~MediaStreamDescriptorClient() { }
virtual void streamEnded() = 0;
virtual void addRemoteTrack(MediaStreamComponent*) = 0;
virtual void removeRemoteTrack(MediaStreamComponent*) = 0;
};
class PLATFORM_EXPORT MediaStreamDescriptor FINAL : public RefCounted<MediaStreamDescriptor> {
public:
class ExtraData {
public:
virtual ~ExtraData() { }
};
static PassRefPtr<MediaStreamDescriptor> create(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources);
static PassRefPtr<MediaStreamDescriptor> create(const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents);
static PassRefPtr<MediaStreamDescriptor> create(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents);
MediaStreamDescriptorClient* client() const { return m_client; }
void setClient(MediaStreamDescriptorClient* client) { m_client = client; }
String id() const { return m_id; }
unsigned numberOfAudioComponents() const { return m_audioComponents.size(); }
MediaStreamComponent* audioComponent(unsigned index) const { return m_audioComponents[index].get(); }
unsigned numberOfVideoComponents() const { return m_videoComponents.size(); }
MediaStreamComponent* videoComponent(unsigned index) const { return m_videoComponents[index].get(); }
void addComponent(PassRefPtr<MediaStreamComponent>);
void removeComponent(PassRefPtr<MediaStreamComponent>);
void addRemoteTrack(MediaStreamComponent*);
void removeRemoteTrack(MediaStreamComponent*);
bool ended() const { return m_ended; }
void setEnded() { m_ended = true; }
ExtraData* extraData() const { return m_extraData.get(); }
void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData; }
private:
MediaStreamDescriptor(const String& id, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources);
MediaStreamDescriptor(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents);
MediaStreamDescriptorClient* m_client;
String m_id;
Vector<RefPtr<MediaStreamComponent> > m_audioComponents;
Vector<RefPtr<MediaStreamComponent> > m_videoComponents;
bool m_ended;
OwnPtr<ExtraData> m_extraData;
};
typedef Vector<RefPtr<MediaStreamDescriptor> > MediaStreamDescriptorVector;
}
#endif