OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
42 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
43 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
44 #include "core/frame/csp/ContentSecurityPolicy.h" | 44 #include "core/frame/csp/ContentSecurityPolicy.h" |
45 #include "core/html/HTMLMediaSource.h" | 45 #include "core/html/HTMLMediaSource.h" |
46 #include "core/html/HTMLSourceElement.h" | 46 #include "core/html/HTMLSourceElement.h" |
47 #include "core/html/HTMLTrackElement.h" | 47 #include "core/html/HTMLTrackElement.h" |
48 #include "core/html/MediaController.h" | 48 #include "core/html/MediaController.h" |
49 #include "core/html/MediaError.h" | 49 #include "core/html/MediaError.h" |
50 #include "core/html/MediaFragmentURIParser.h" | 50 #include "core/html/MediaFragmentURIParser.h" |
| 51 #include "core/html/MediaProvider.h" |
51 #include "core/html/TimeRanges.h" | 52 #include "core/html/TimeRanges.h" |
52 #include "core/html/shadow/MediaControls.h" | 53 #include "core/html/shadow/MediaControls.h" |
53 #include "core/html/track/AudioTrack.h" | 54 #include "core/html/track/AudioTrack.h" |
54 #include "core/html/track/AudioTrackList.h" | 55 #include "core/html/track/AudioTrackList.h" |
55 #include "core/html/track/InbandTextTrack.h" | 56 #include "core/html/track/InbandTextTrack.h" |
56 #include "core/html/track/TextTrackCueList.h" | 57 #include "core/html/track/TextTrackCueList.h" |
57 #include "core/html/track/TextTrackList.h" | 58 #include "core/html/track/TextTrackList.h" |
58 #include "core/html/track/VideoTrack.h" | 59 #include "core/html/track/VideoTrack.h" |
59 #include "core/html/track/VideoTrackList.h" | 60 #include "core/html/track/VideoTrackList.h" |
60 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 676 } |
676 | 677 |
677 m_pendingActionFlags = 0; | 678 m_pendingActionFlags = 0; |
678 } | 679 } |
679 | 680 |
680 PassRefPtrWillBeRawPtr<MediaError> HTMLMediaElement::error() const | 681 PassRefPtrWillBeRawPtr<MediaError> HTMLMediaElement::error() const |
681 { | 682 { |
682 return m_error; | 683 return m_error; |
683 } | 684 } |
684 | 685 |
| 686 void HTMLMediaElement::setSrcObject(PassRefPtrWillBeRawPtr<MediaProvider> mediaP
rovider) |
| 687 { |
| 688 m_srcObject = mediaProvider; |
| 689 clearMediaPlayer(LoadMediaResource); |
| 690 scheduleDelayedAction(LoadMediaResource); |
| 691 } |
| 692 |
| 693 MediaProvider* HTMLMediaElement::srcObject() const { |
| 694 return m_srcObject.get(); |
| 695 } |
| 696 |
685 void HTMLMediaElement::setSrc(const AtomicString& url) | 697 void HTMLMediaElement::setSrc(const AtomicString& url) |
686 { | 698 { |
687 setAttribute(srcAttr, url); | 699 setAttribute(srcAttr, url); |
688 } | 700 } |
689 | 701 |
690 HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const | 702 HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const |
691 { | 703 { |
692 return m_networkState; | 704 return m_networkState; |
693 } | 705 } |
694 | 706 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 } | 860 } |
849 } | 861 } |
850 | 862 |
851 selectMediaResource(); | 863 selectMediaResource(); |
852 } | 864 } |
853 | 865 |
854 void HTMLMediaElement::selectMediaResource() | 866 void HTMLMediaElement::selectMediaResource() |
855 { | 867 { |
856 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource"); | 868 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource"); |
857 | 869 |
858 enum Mode { attribute, children }; | 870 enum Mode {Object, Attribute, Children}; |
859 | 871 |
860 // 3 - If the media element has a src attribute, then let mode be attribute. | 872 // 3 - Decide which source to load. |
861 Mode mode = attribute; | 873 // If the media element has a srcObject let the mode be object. |
862 if (!fastHasAttribute(srcAttr)) { | 874 // If it has a src attribute, let the mode be attribute. |
863 // Otherwise, if the media element does not have a src attribute but has
a source | 875 // If it has a source element, let the mode be Children. |
864 // element child, then let mode be children and let candidate be the fir
st such | 876 Mode mode = Object; |
865 // source element child in tree order. | 877 if (m_srcObject) { |
866 if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChil
d(*this)) { | 878 mode = Object; |
867 mode = children; | 879 } else if (fastHasAttribute(srcAttr)) { |
868 m_nextChildNodeToConsider = element; | 880 mode = Attribute; |
869 m_currentSourceNode = nullptr; | 881 } else if (Traversal<HTMLSourceElement>::firstChild(*this)) { |
870 } else { | 882 mode = Children; |
871 // Otherwise the media element has neither a src attribute nor a sou
rce element | 883 HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChild(*t
his); |
872 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the | 884 m_nextChildNodeToConsider = element; |
873 // synchronous section ends. | 885 m_currentSourceNode = nullptr; |
874 m_loadState = WaitingForSource; | 886 } else { |
875 setShouldDelayLoadEvent(false); | 887 // Otherwise the media element has no source. |
876 m_networkState = NETWORK_EMPTY; | 888 // set the networkState to NETWORK_EMPTY, and abort these steps; the |
| 889 // synchronous section ends. |
| 890 m_loadState = WaitingForSource; |
| 891 setShouldDelayLoadEvent(false); |
| 892 m_networkState = NETWORK_EMPTY; |
877 | 893 |
878 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to lo
ad"); | 894 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to load")
; |
879 return; | 895 return; |
880 } | |
881 } | 896 } |
882 | 897 |
883 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), | 898 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), |
884 // and set its networkState to NETWORK_LOADING. | 899 // and set its networkState to NETWORK_LOADING. |
885 setShouldDelayLoadEvent(true); | 900 setShouldDelayLoadEvent(true); |
886 m_networkState = NETWORK_LOADING; | 901 m_networkState = NETWORK_LOADING; |
887 | 902 |
888 // 5 - Queue a task to fire a simple event named loadstart at the media elem
ent. | 903 // 5 - Queue a task to fire a simple event named loadstart at the media elem
ent. |
889 scheduleEvent(EventTypeNames::loadstart); | 904 scheduleEvent(EventTypeNames::loadstart); |
890 | 905 |
891 // 6 - If mode is attribute, then run these substeps | 906 // 6 - Load the correct source. |
892 if (mode == attribute) { | 907 switch (mode) { |
893 m_loadState = LoadingFromSrcAttr; | 908 case Object: |
| 909 loadSourceFromObject(); |
| 910 break; |
| 911 case Attribute: |
| 912 loadSourceFromAttribute(); |
| 913 break; |
| 914 case Children: |
| 915 loadNextSourceChild(); |
| 916 break; |
| 917 } |
| 918 } |
894 | 919 |
895 // If the src attribute's value is the empty string ... jump down to the
failed step below | 920 void HTMLMediaElement::loadSourceFromObject() |
896 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); | 921 { |
897 if (mediaURL.isEmpty()) { | 922 m_loadState = LoadingFromSrcObject; |
898 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
899 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, empty 'src'")
; | |
900 return; | |
901 } | |
902 | 923 |
903 if (!isSafeToLoadURL(mediaURL, Complain)) { | 924 KURL mediaURL = document().completeURL(m_srcObject->createObjectUrl()); |
904 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
905 return; | |
906 } | |
907 | 925 |
908 // No type or key system information is available when the url comes | 926 if (!isSafeToLoadURL(mediaURL, Complain)) { |
909 // from the 'src' attribute so MediaPlayer | 927 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
910 // will have to pick a media engine based on the file extension. | |
911 ContentType contentType((String())); | |
912 loadResource(mediaURL, contentType, String()); | |
913 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'src' attri
bute url"); | |
914 return; | 928 return; |
915 } | 929 } |
916 | 930 |
917 // Otherwise, the source elements will be used | 931 // No type or key system information is available when the url comes |
918 loadNextSourceChild(); | 932 // from the 'srcObject' so MediaPlayer |
| 933 // will have to pick a media engine based on the file extension. |
| 934 ContentType contentType((String())); |
| 935 loadResource(mediaURL, contentType, String()); |
| 936 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'srcObject' att
ribute."); |
| 937 return; |
| 938 } |
| 939 |
| 940 void HTMLMediaElement::loadSourceFromAttribute() |
| 941 { |
| 942 m_loadState = LoadingFromSrcAttr; |
| 943 |
| 944 // If the src attribute's value is the empty string ... jump down to the fai
led step below |
| 945 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); |
| 946 if (mediaURL.isEmpty()) { |
| 947 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 948 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, empty 'src'"); |
| 949 return; |
| 950 } |
| 951 |
| 952 if (!isSafeToLoadURL(mediaURL, Complain)) { |
| 953 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 954 return; |
| 955 } |
| 956 |
| 957 // No type or key system information is available when the url comes |
| 958 // from the 'src' attribute so MediaPlayer |
| 959 // will have to pick a media engine based on the file extension. |
| 960 ContentType contentType((String())); |
| 961 loadResource(mediaURL, contentType, String()); |
| 962 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'src' attribute
url"); |
| 963 return; |
919 } | 964 } |
920 | 965 |
921 void HTMLMediaElement::loadNextSourceChild() | 966 void HTMLMediaElement::loadNextSourceChild() |
922 { | 967 { |
923 ContentType contentType((String())); | 968 ContentType contentType((String())); |
924 String keySystem; | 969 String keySystem; |
925 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); | 970 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); |
926 if (!mediaURL.isValid()) { | 971 if (!mediaURL.isValid()) { |
927 waitForSourceChange(); | 972 waitForSourceChange(); |
928 return; | 973 return; |
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3989 | 4034 |
3990 #if ENABLE(WEB_AUDIO) | 4035 #if ENABLE(WEB_AUDIO) |
3991 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4036 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3992 { | 4037 { |
3993 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4038 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
3994 audioSourceProvider()->setClient(0); | 4039 audioSourceProvider()->setClient(0); |
3995 } | 4040 } |
3996 #endif | 4041 #endif |
3997 | 4042 |
3998 } | 4043 } |
OLD | NEW |