mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-19 23:07:33 +09:00
Allow matroska mime types for video element and MSE
Allow avc (h.264) content in matroska/webm containers
This commit is contained in:
parent
3829b269ce
commit
a960d679d5
8 changed files with 44 additions and 5 deletions
|
|
@ -180,7 +180,8 @@ bool
|
|||
MP4Decoder::IsH264(const nsACString& aMimeType)
|
||||
{
|
||||
return aMimeType.EqualsLiteral("video/mp4") ||
|
||||
aMimeType.EqualsLiteral("video/avc");
|
||||
aMimeType.EqualsLiteral("video/avc") ||
|
||||
aMimeType.EqualsLiteral("video/webm; codecs=avc1");
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
|||
|
|
@ -697,6 +697,9 @@ ContainerParser::CreateForMIMEType(const nsACString& aType)
|
|||
if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) {
|
||||
return new WebMContainerParser(aType);
|
||||
}
|
||||
if (aType.LowerCaseEqualsLiteral("video/x-matroska")) {
|
||||
return new WebMContainerParser(aType);
|
||||
}
|
||||
|
||||
#ifdef MOZ_FMP4
|
||||
if (aType.LowerCaseEqualsLiteral("video/mp4") || aType.LowerCaseEqualsLiteral("audio/mp4")) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* a
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (mimeType.EqualsASCII("video/webm")) {
|
||||
if (mimeType.EqualsASCII("video/webm") ||
|
||||
mimeType.EqualsASCII("video/x-matroska")) {
|
||||
if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
|
||||
IsWebMForced(aDiagnostics))) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
|
|
|
|||
|
|
@ -814,6 +814,7 @@ TrackBuffersManager::CreateDemuxerforMIMEType()
|
|||
ShutdownDemuxers();
|
||||
|
||||
if (mType.LowerCaseEqualsLiteral("video/webm") ||
|
||||
mType.LowerCaseEqualsLiteral("video/x-matroska") ||
|
||||
mType.LowerCaseEqualsLiteral("audio/webm")) {
|
||||
mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/ );
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs,
|
|||
}
|
||||
|
||||
const bool isWebMAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/webm");
|
||||
const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm");
|
||||
const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ;
|
||||
if (!isWebMAudio && !isWebMVideo) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -74,6 +74,11 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs,
|
|||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IsH264CodecString(codec)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some unsupported codec.
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -326,6 +326,20 @@ WebMDemuxer::ReadMetadata()
|
|||
case NESTEGG_CODEC_AV1:
|
||||
mInfo.mVideo.mMimeType = "video/webm; codecs=av1";
|
||||
break;
|
||||
case NESTEGG_CODEC_AVC1: {
|
||||
mInfo.mVideo.mMimeType = "video/webm; codecs=avc1";
|
||||
|
||||
unsigned char* data = 0;
|
||||
size_t length = 0;
|
||||
r = nestegg_track_codec_data(context, track, 0, &data, &length);
|
||||
if (r == -1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mInfo.mVideo.mExtraData = new MediaByteBuffer(length);
|
||||
mInfo.mVideo.mExtraData->AppendElements(data, length);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_WARNING("Unknown WebM video codec");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
@ -662,6 +676,9 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
|
|||
isKeyframe = AOMDecoder::IsKeyframe(sample);
|
||||
break;
|
||||
#endif
|
||||
case NESTEGG_CODEC_AVC1:
|
||||
isKeyframe = nestegg_packet_has_keyframe(holder->Packet());
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Cannot detect keyframes in unknown WebM video codec");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
@ -682,7 +699,7 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
|
|||
dimensions = AOMDecoder::GetFrameSize(sample);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (mLastSeenFrameSize.isSome()
|
||||
&& (dimensions != mLastSeenFrameSize.value())) {
|
||||
mInfo.mVideo.mDisplay = dimensions;
|
||||
|
|
@ -749,6 +766,11 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
|
|||
if (aType == TrackInfo::kVideoTrack) {
|
||||
sample->mTrackInfo = mSharedVideoTrackInfo;
|
||||
}
|
||||
|
||||
if (mVideoCodec == NESTEGG_CODEC_AVC1) {
|
||||
sample->mExtraData = mInfo.mVideo.mExtraData;
|
||||
}
|
||||
|
||||
aSamples->Push(sample);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue