Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 DCHECK(m_source); 583 DCHECK(m_source);
584 DCHECK(m_source->mediaElement()); 584 DCHECK(m_source->mediaElement());
585 DCHECK(m_updating); 585 DCHECK(m_updating);
586 586
587 // TODO(servolk): Implement proper 'initialization segment received' algorit hm according to MSE spec: 587 // TODO(servolk): Implement proper 'initialization segment received' algorit hm according to MSE spec:
588 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received 588 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received
589 WebVector<WebMediaPlayer::TrackId> result(newTracks.size()); 589 WebVector<WebMediaPlayer::TrackId> result(newTracks.size());
590 unsigned resultIdx = 0; 590 unsigned resultIdx = 0;
591 for (const auto& trackInfo : newTracks) { 591 for (const auto& trackInfo : newTracks) {
592 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { 592 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) {
593 static WebMediaPlayer::TrackId nextTrackId = 0; 593 static unsigned nextTrackId = 0;
594 result[resultIdx++] = ++nextTrackId; 594 StringBuilder stringBuilder;
595 stringBuilder.appendNumber(++nextTrackId);
596 result[resultIdx++] = stringBuilder.toString();
595 continue; 597 continue;
596 } 598 }
597 599
598 const TrackBase* trackBase = nullptr; 600 const TrackBase* trackBase = nullptr;
599 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { 601 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) {
600 AudioTrack* audioTrack = nullptr; 602 AudioTrack* audioTrack = nullptr;
601 if (!m_firstInitializationSegmentReceived) { 603 if (!m_firstInitializationSegmentReceived) {
602 audioTrack = AudioTrack::create(trackInfo.byteStreamTrackId, tra ckInfo.kind, trackInfo.label, trackInfo.language, false); 604 audioTrack = AudioTrack::create(trackInfo.id, trackInfo.kind, tr ackInfo.label, trackInfo.language, false);
603 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, th is); 605 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, th is);
604 audioTracks().add(audioTrack); 606 audioTracks().add(audioTrack);
605 m_source->mediaElement()->audioTracks().add(audioTrack); 607 m_source->mediaElement()->audioTracks().add(audioTrack);
606 } else { 608 } else {
607 audioTrack = findExistingTrackById(audioTracks(), trackInfo.byte StreamTrackId); 609 audioTrack = findExistingTrackById(audioTracks(), trackInfo.id);
608 DCHECK(audioTrack); 610 DCHECK(audioTrack);
609 } 611 }
610 trackBase = audioTrack; 612 trackBase = audioTrack;
611 result[resultIdx++] = audioTrack->trackId(); 613 result[resultIdx++] = audioTrack->trackId();
612 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { 614 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) {
613 VideoTrack* videoTrack = nullptr; 615 VideoTrack* videoTrack = nullptr;
614 if (!m_firstInitializationSegmentReceived) { 616 if (!m_firstInitializationSegmentReceived) {
615 videoTrack = VideoTrack::create(trackInfo.byteStreamTrackId, tra ckInfo.kind, trackInfo.label, trackInfo.language, false); 617 videoTrack = VideoTrack::create(trackInfo.id, trackInfo.kind, tr ackInfo.label, trackInfo.language, false);
616 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, th is); 618 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, th is);
617 videoTracks().add(videoTrack); 619 videoTracks().add(videoTrack);
618 m_source->mediaElement()->videoTracks().add(videoTrack); 620 m_source->mediaElement()->videoTracks().add(videoTrack);
619 } else { 621 } else {
620 videoTrack = findExistingTrackById(videoTracks(), trackInfo.byte StreamTrackId); 622 videoTrack = findExistingTrackById(videoTracks(), trackInfo.id);
621 DCHECK(videoTrack); 623 DCHECK(videoTrack);
622 } 624 }
623 trackBase = videoTrack; 625 trackBase = videoTrack;
624 result[resultIdx++] = videoTrack->trackId(); 626 result[resultIdx++] = videoTrack->trackId();
625 } else { 627 } else {
626 NOTREACHED(); 628 NOTREACHED();
627 } 629 }
628 (void)trackBase; 630 (void)trackBase;
629 #if !LOG_DISABLED 631 #if !LOG_DISABLED
630 const char* logActionStr = m_firstInitializationSegmentReceived ? "using existing" : "added"; 632 const char* logActionStr = m_firstInitializationSegmentReceived ? "using existing" : "added";
631 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au dioTrack) ? "audio" : "video"; 633 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au dioTrack) ? "audio" : "video";
632 DVLOG(SOURCE_BUFFER_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") " << logActionStr << " " 634 DVLOG(SOURCE_BUFFER_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") " << logActionStr << " "
633 << logTrackTypeStr << " Track " << trackBase << "trackId=" << trackB ase->trackId() << " id=" 635 << logTrackTypeStr << " Track " << trackBase << " trackId=" << (Stri ng)trackBase->trackId()
634 << trackBase->id() << " label=" << trackBase->label() << " lang=" << trackBase->language(); 636 << " label=" << trackBase->label() << " lang=" << trackBase->languag e();
635 #endif 637 #endif
636 } 638 }
637 639
638 if (!m_firstInitializationSegmentReceived) { 640 if (!m_firstInitializationSegmentReceived) {
639 // 5. If active track flag equals true, then run the following steps: 641 // 5. If active track flag equals true, then run the following steps:
640 // 5.1. Add this SourceBuffer to activeSourceBuffers. 642 // 5.1. Add this SourceBuffer to activeSourceBuffers.
641 // 5.2. Queue a task to fire a simple event named addsourcebuffer at 643 // 5.2. Queue a task to fire a simple event named addsourcebuffer at
642 // activesourcebuffers. 644 // activesourcebuffers.
643 m_source->setSourceBufferActive(this); 645 m_source->setSourceBufferActive(this);
644 646
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 visitor->trace(m_removeAsyncPartRunner); 1028 visitor->trace(m_removeAsyncPartRunner);
1027 visitor->trace(m_appendStreamAsyncPartRunner); 1029 visitor->trace(m_appendStreamAsyncPartRunner);
1028 visitor->trace(m_stream); 1030 visitor->trace(m_stream);
1029 visitor->trace(m_audioTracks); 1031 visitor->trace(m_audioTracks);
1030 visitor->trace(m_videoTracks); 1032 visitor->trace(m_videoTracks);
1031 EventTargetWithInlineData::trace(visitor); 1033 EventTargetWithInlineData::trace(visitor);
1032 ActiveDOMObject::trace(visitor); 1034 ActiveDOMObject::trace(visitor);
1033 } 1035 }
1034 1036
1035 } // namespace blink 1037 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698