OLD | NEW |
---|---|
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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 { | 498 { |
499 // According to MSE specification (https://w3c.github.io/media-source/#sourc ebuffer-init-segment-received) step 3.1: | 499 // According to MSE specification (https://w3c.github.io/media-source/#sourc ebuffer-init-segment-received) step 3.1: |
500 // > If more than one track for a single type are present (ie 2 audio tracks ), then the Track IDs match the ones in the first initialization segment. | 500 // > If more than one track for a single type are present (ie 2 audio tracks ), then the Track IDs match the ones in the first initialization segment. |
501 // I.e. we only need to search by TrackID if there is more than one track, o therwise we can assume that the only | 501 // I.e. we only need to search by TrackID if there is more than one track, o therwise we can assume that the only |
502 // track of the given type is the same one that we had in previous init segm ents. | 502 // track of the given type is the same one that we had in previous init segm ents. |
503 if (trackList.length() == 1) | 503 if (trackList.length() == 1) |
504 return trackList.anonymousIndexedGetter(0); | 504 return trackList.anonymousIndexedGetter(0); |
505 return trackList.getTrackById(id); | 505 return trackList.getTrackById(id); |
506 } | 506 } |
507 | 507 |
508 std::vector<WebMediaPlayer::TrackId> SourceBuffer::initializationSegmentReceived (const std::vector<MediaTrackInfo>& newTracks) | 508 WebVector<WebMediaPlayer::TrackId> SourceBuffer::initializationSegmentReceived(c onst WebVector<MediaTrackInfo>& newTracks) |
509 { | 509 { |
510 WTF_LOG(Media, "SourceBuffer::initializationSegmentReceived %p tracks=%zu", this, newTracks.size()); | 510 WTF_LOG(Media, "SourceBuffer::initializationSegmentReceived %p tracks=%zu", this, newTracks.size()); |
511 ASSERT(m_source); | 511 ASSERT(m_source); |
512 ASSERT(m_source->mediaElement()); | 512 ASSERT(m_source->mediaElement()); |
513 ASSERT(m_updating); | 513 ASSERT(m_updating); |
514 | 514 |
515 // TODO(servolk): Implement proper 'initialization segment received' algorit hm according to MSE spec: | 515 // TODO(servolk): Implement proper 'initialization segment received' algorit hm according to MSE spec: |
516 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received | 516 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received |
517 std::vector<WebMediaPlayer::TrackId> result; | 517 WebVector<WebMediaPlayer::TrackId> result(newTracks.size()); |
518 unsigned resultIdx = 0; | |
518 for (const auto& trackInfo : newTracks) { | 519 for (const auto& trackInfo : newTracks) { |
519 const auto& trackType = std::get<0>(trackInfo); | |
520 const auto& id = std::get<1>(trackInfo); | |
521 const auto& kind = std::get<2>(trackInfo); | |
522 const auto& label = std::get<3>(trackInfo); | |
523 const auto& language = std::get<4>(trackInfo); | |
524 | |
525 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 520 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { |
526 static WebMediaPlayer::TrackId nextTrackId = 0; | 521 static WebMediaPlayer::TrackId nextTrackId = 0; |
527 result.push_back(++nextTrackId); | 522 result[resultIdx++] = ++nextTrackId; |
wolenetz
2016/04/19 22:35:02
nit: I'm not sure it's really nextTrackId, since p
servolk
2016/04/19 22:50:10
As I've explained offline this is actually to emul
| |
528 continue; | 523 continue; |
529 } | 524 } |
530 | 525 |
531 const TrackBase* trackBase = nullptr; | 526 const TrackBase* trackBase = nullptr; |
532 if (trackType == WebMediaPlayer::AudioTrack) { | 527 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { |
533 AudioTrack* audioTrack = nullptr; | 528 AudioTrack* audioTrack = nullptr; |
534 if (!m_firstInitializationSegmentReceived) { | 529 if (!m_firstInitializationSegmentReceived) { |
535 audioTrack = AudioTrack::create(id, kind, label, language, false ); | 530 audioTrack = AudioTrack::create(trackInfo.byteStreamTrackId, tra ckInfo.kind, trackInfo.label, trackInfo.language, false); |
536 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, th is); | 531 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, th is); |
537 audioTracks().add(audioTrack); | 532 audioTracks().add(audioTrack); |
538 m_source->mediaElement()->audioTracks().add(audioTrack); | 533 m_source->mediaElement()->audioTracks().add(audioTrack); |
539 } else { | 534 } else { |
540 audioTrack = findExistingTrackById(audioTracks(), id); | 535 audioTrack = findExistingTrackById(audioTracks(), trackInfo.byte StreamTrackId); |
541 ASSERT(audioTrack); | 536 ASSERT(audioTrack); |
542 } | 537 } |
543 trackBase = audioTrack; | 538 trackBase = audioTrack; |
544 result.push_back(audioTrack->trackId()); | 539 result[resultIdx++] = audioTrack->trackId(); |
545 } else if (trackType == WebMediaPlayer::VideoTrack) { | 540 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { |
546 VideoTrack* videoTrack = nullptr; | 541 VideoTrack* videoTrack = nullptr; |
547 if (!m_firstInitializationSegmentReceived) { | 542 if (!m_firstInitializationSegmentReceived) { |
548 videoTrack = VideoTrack::create(id, kind, label, language, false ); | 543 videoTrack = VideoTrack::create(trackInfo.byteStreamTrackId, tra ckInfo.kind, trackInfo.label, trackInfo.language, false); |
549 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, th is); | 544 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, th is); |
550 videoTracks().add(videoTrack); | 545 videoTracks().add(videoTrack); |
551 m_source->mediaElement()->videoTracks().add(videoTrack); | 546 m_source->mediaElement()->videoTracks().add(videoTrack); |
552 } else { | 547 } else { |
553 videoTrack = findExistingTrackById(videoTracks(), id); | 548 videoTrack = findExistingTrackById(videoTracks(), trackInfo.byte StreamTrackId); |
554 ASSERT(videoTrack); | 549 ASSERT(videoTrack); |
555 } | 550 } |
556 trackBase = videoTrack; | 551 trackBase = videoTrack; |
557 result.push_back(videoTrack->trackId()); | 552 result[resultIdx++] = videoTrack->trackId(); |
558 } else { | 553 } else { |
559 NOTREACHED(); | 554 NOTREACHED(); |
560 } | 555 } |
561 (void)trackBase; | 556 (void)trackBase; |
562 #if !LOG_DISABLED | 557 #if !LOG_DISABLED |
563 const char* logActionStr = m_firstInitializationSegmentReceived ? "using existing" : "added"; | 558 const char* logActionStr = m_firstInitializationSegmentReceived ? "using existing" : "added"; |
564 const char* logTrackTypeStr = (trackType == WebMediaPlayer::AudioTrack) ? "audio" : "video"; | 559 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au dioTrack) ? "audio" : "video"; |
565 WTF_LOG(Media, "Tracks (sb=%p): %s %sTrack %p trackId=%d id=%s label=%s lang=%s", this, logActionStr, logTrackTypeStr, trackBase, trackBase->trackId(), trackBase->id().utf8().data(), trackBase->label().utf8().data(), trackBase->lang uage().utf8().data()); | 560 WTF_LOG(Media, "Tracks (sb=%p): %s %sTrack %p trackId=%d id=%s label=%s lang=%s", this, logActionStr, logTrackTypeStr, trackBase, trackBase->trackId(), trackBase->id().utf8().data(), trackBase->label().utf8().data(), trackBase->lang uage().utf8().data()); |
566 #endif | 561 #endif |
567 } | 562 } |
568 | 563 |
569 if (!m_firstInitializationSegmentReceived) { | 564 if (!m_firstInitializationSegmentReceived) { |
570 // 5. If active track flag equals true, then run the following steps: | 565 // 5. If active track flag equals true, then run the following steps: |
571 // 5.1. Add this SourceBuffer to activeSourceBuffers. | 566 // 5.1. Add this SourceBuffer to activeSourceBuffers. |
572 // 5.2. Queue a task to fire a simple event named addsourcebuffer at | 567 // 5.2. Queue a task to fire a simple event named addsourcebuffer at |
573 // activesourcebuffers. | 568 // activesourcebuffers. |
574 m_source->setSourceBufferActive(this); | 569 m_source->setSourceBufferActive(this); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 visitor->trace(m_removeAsyncPartRunner); | 953 visitor->trace(m_removeAsyncPartRunner); |
959 visitor->trace(m_appendStreamAsyncPartRunner); | 954 visitor->trace(m_appendStreamAsyncPartRunner); |
960 visitor->trace(m_stream); | 955 visitor->trace(m_stream); |
961 visitor->trace(m_audioTracks); | 956 visitor->trace(m_audioTracks); |
962 visitor->trace(m_videoTracks); | 957 visitor->trace(m_videoTracks); |
963 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor); | 958 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor); |
964 ActiveDOMObject::trace(visitor); | 959 ActiveDOMObject::trace(visitor); |
965 } | 960 } |
966 | 961 |
967 } // namespace blink | 962 } // namespace blink |
OLD | NEW |