MediaFormatReader.h [plain text]
#pragma once
#if ENABLE(WEBM_FORMAT_READER)
#include "CoreMediaWrapped.h"
#include <WebCore/SourceBufferPrivateClient.h>
#include <wtf/Condition.h>
#include <wtf/Lock.h>
#include <wtf/Logger.h>
DECLARE_CORE_MEDIA_TRAITS(FormatReader);
namespace WebCore {
class SourceBufferParser;
}
namespace WebKit {
class MediaTrackReader;
class MediaFormatReader final : public CoreMediaWrapped<MediaFormatReader> {
public:
using CoreMediaWrapped<MediaFormatReader>::unwrap;
static constexpr WrapperClass wrapperClass();
static CMBaseClassID wrapperClassID();
static CoreMediaWrapped<MediaFormatReader>* unwrap(CMBaseObjectRef);
static RefPtr<MediaFormatReader> create(Allocator&&);
void startOnMainThread(MTPluginByteSourceRef);
const MediaTime& duration() const { return m_duration; }
const Logger& logger() const { ASSERT(m_logger); return *m_logger.get(); }
const void* nextTrackReaderLogIdentifier(uint64_t) const;
private:
explicit MediaFormatReader(Allocator&&);
void parseByteSource(RetainPtr<MTPluginByteSourceRef>&&);
void didParseTracks(WebCore::SourceBufferPrivateClient::InitializationSegment&&, uint64_t errorCode);
void didSelectVideoTrack(WebCore::VideoTrackPrivate&, bool) { }
void didEnableAudioTrack(WebCore::AudioTrackPrivate&, bool) { }
void didProvideMediaData(Ref<WebCore::MediaSample>&&, uint64_t, const String&);
void finishParsing(Ref<WebCore::SourceBufferParser>&&);
String debugDescription() const final { return "WebKit::MediaFormatReader"_s; }
OSStatus copyProperty(CFStringRef, CFAllocatorRef, void* copiedValue) final;
OSStatus copyTrackArray(CFArrayRef*);
const void* logIdentifier() const { return m_logIdentifier; }
RetainPtr<MTPluginByteSourceRef> m_byteSource;
Condition m_parseTracksCondition;
Lock m_parseTracksLock;
MediaTime m_duration;
Optional<OSStatus> m_parseTracksStatus;
Vector<Ref<MediaTrackReader>> m_trackReaders;
RefPtr<const Logger> m_logger;
const void* m_logIdentifier;
};
constexpr MediaFormatReader::WrapperClass MediaFormatReader::wrapperClass()
{
return {
.version = kMTPluginFormatReader_ClassVersion_1,
.copyTrackArray = [](WrapperRef reader, CFArrayRef* trackArrayCopy) {
return unwrap(reader)->copyTrackArray(trackArrayCopy);
},
};
}
}
#endif // ENABLE(WEBM_FORMAT_READER)