diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-05-07 13:40:21 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-05-07 13:40:21 +0200 |
commit | 7e1f4f430f7e834b7cea7a010d7b8efd576851fe (patch) | |
tree | 041b582a0b6cac0628cb94e5109515c6ba66e6e5 /dom/media/mediasource/ContainerParser.cpp | |
parent | c31fe286b915751e2ea3e9d3531442fabcd370fc (diff) | |
download | UXP-7e1f4f430f7e834b7cea7a010d7b8efd576851fe.tar UXP-7e1f4f430f7e834b7cea7a010d7b8efd576851fe.tar.gz UXP-7e1f4f430f7e834b7cea7a010d7b8efd576851fe.tar.lz UXP-7e1f4f430f7e834b7cea7a010d7b8efd576851fe.tar.xz UXP-7e1f4f430f7e834b7cea7a010d7b8efd576851fe.zip |
Issue #1536 - Part 2: Parse content to decide whether it's a media segment.
Diffstat (limited to 'dom/media/mediasource/ContainerParser.cpp')
-rw-r--r-- | dom/media/mediasource/ContainerParser.cpp | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/dom/media/mediasource/ContainerParser.cpp b/dom/media/mediasource/ContainerParser.cpp index b4dcfde8a..628f8d7cd 100644 --- a/dom/media/mediasource/ContainerParser.cpp +++ b/dom/media/mediasource/ContainerParser.cpp @@ -154,31 +154,20 @@ public: MediaResult IsMediaSegmentPresent(MediaByteBuffer* aData) override { ContainerParser::IsMediaSegmentPresent(aData); - // XXX: This is overly primitive, needs to collect data as it's appended - // to the SB and handle, rather than assuming everything is present in a - // single aData segment. - // 0x1a45dfa3 // EBML - // ... - // DocType == "webm" - // ... - // 0x18538067 // Segment (must be "unknown" size) - // 0x1549a966 // -> Segment Info - // 0x1654ae6b // -> One or more Tracks - - // 0x1f43b675 // Cluster if (aData->Length() < 4) { return NS_ERROR_NOT_AVAILABLE; } - if ((*aData)[0] == 0x1f && (*aData)[1] == 0x43 && (*aData)[2] == 0xb6 && - (*aData)[3] == 0x75) { - return NS_OK; - } - // 0x1c53bb6b // Cues - if ((*aData)[0] == 0x1c && (*aData)[1] == 0x53 && (*aData)[2] == 0xbb && - (*aData)[3] == 0x6b) { - return NS_OK; + + WebMBufferedParser parser(0); + nsTArray<WebMTimeDataOffset> mapping; + ReentrantMonitor dummy("dummy"); + parser.AppendMediaSegmentOnly(); + bool result = parser.Append(aData->Elements(), aData->Length(), mapping, + dummy); + if (!result) { + return MediaResult(NS_ERROR_FAILURE, RESULT_DETAIL("Invalid webm content")); } - return MediaResult(NS_ERROR_FAILURE, RESULT_DETAIL("Invalid webm content")); + return parser.GetClusterOffset() >= 0 ? NS_OK : NS_ERROR_NOT_AVAILABLE; } MediaResult ParseStartAndEndTimestamps(MediaByteBuffer* aData, |