[webkit-dev] compile failure when I try to introduce GLContextEGL to MediaPlayerPrivateGStreamer

Simon Hausmann simon.hausmann at digia.com
Fri Nov 9 00:27:58 PST 2012


On Friday, November 09, 2012 02:16:33 AM Zhao, Halley wrote:
> when using "g++ -E", I found the issue after pre-processing: (thanks
> suggestion from Philippe) After include GLContextEGL.h, MediaPlayer::None
> changes to MediaPlayer::0L after pre-processing.

Ah, that's a classic. It's a macro the X11 headers define.
 
> Though I don't find the definition of None from new code introduced by
> GLContextEGL.h, I do think it is not good habit to use 'None' in such as
> big project; so I try to replace 'None' to PlatformMedia::PlayerTypeNone
> and MediaPlayer::PreloadLoadNone. It fixed my issue:

I don't think we should do that. None is a perfectly fine identifier to use in 
an enum the way it is. It's the X11 headers that are broken and the usual 
workaround is to do things like

    #undef None

after including them. That should probably happen in GLContextEGL.h or even 
nearer to the inclusion.

Simon
 
> Here is the patch for your reference:
> 
> From d684bbbc34ea241f123544711bbad4ff58a06ebf Mon Sep 17 00:00:00 2001
> From: Zhao Halley <halley.zhao at intel.com>
> Date: Fri, 9 Nov 2012 09:50:27 +0800
> Subject: [PATCH] redefine MediaPlayer::None to MediaPlayer::PreloadNone or
> MediaPlayer::PlayerTypeNone
> 
> ---
> Source/WebCore/html/HTMLMediaElement.cpp           |    4 ++--
> Source/WebCore/platform/graphics/MediaPlayer.cpp   |    2 +-
> Source/WebCore/platform/graphics/MediaPlayer.h     |    4 ++--
> .../gstreamer/MediaPlayerPrivateGStreamer.cpp      |    8 ++++----
> .../graphics/mac/MediaPlayerPrivateQTKit.mm        |    4 ++--
> .../platform/graphics/qt/MediaPlayerPrivateQt.cpp  |    4 ++--
> .../MediaPlayerPrivateQuickTimeVisualContext.cpp   |    4 ++--
> Source/WebKit/chromium/src/AssertMatchingEnums.cpp |    2 +-
> .../chromium/src/WebMediaPlayerClientImpl.cpp      |    4 ++--
> 9 files changed, 18 insertions(+), 18 deletions(-)
> mode change 100644 => 100755
> Source/WebCore/platform/graphics/MediaPlayer.cpp mode change 100644 =>
> 100755 Source/WebCore/platform/graphics/MediaPlayer.h mode change 100644 =>
> 100755
> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
> mode change 100644 => 100755
> Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp mode change
> 100644 => 100755
> Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualConte
> xt.cpp
> 
> diff --git a/Source/WebCore/html/HTMLMediaElement.cpp
> b/Source/WebCore/html/HTMLMediaElement.cpp index ebeee1b..d9f1691 100644
> --- a/Source/WebCore/html/HTMLMediaElement.cpp
> +++ b/Source/WebCore/html/HTMLMediaElement.cpp
> @@ -364,7 +364,7 @@ void HTMLMediaElement::parseAttribute(const Attribute&
> attribute) #endif
>      else if (attribute.name() == preloadAttr) {
>          if (equalIgnoringCase(attribute.value(), "none"))
> -            m_preload = MediaPlayer::None;
> +            m_preload = MediaPlayer::PreloadNone;
>          else if (equalIgnoringCase(attribute.value(), "metadata"))
>              m_preload = MediaPlayer::MetaData;
>          else {
> @@ -2263,7 +2263,7 @@ void HTMLMediaElement::setAutoplay(bool b)
> String HTMLMediaElement::preload() const
> {
>      switch (m_preload) {
> -    case MediaPlayer::None:
> +    case MediaPlayer::PreloadNone:
>          return "none";
>          break;
>      case MediaPlayer::MetaData:
> diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp
> b/Source/WebCore/platform/graphics/MediaPlayer.cpp old mode 100644
> new mode 100755
> index 377e8dc..1977c8a
> --- a/Source/WebCore/platform/graphics/MediaPlayer.cpp
> +++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp
> @@ -79,7 +79,7 @@
>  namespace WebCore {
> -const PlatformMedia NoPlatformMedia = { PlatformMedia::None, {0} };
> +const PlatformMedia NoPlatformMedia = { PlatformMedia::PlayerTypeNone, {0}
> }; // a null player to make MediaPlayer logic simpler
> diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h
> b/Source/WebCore/platform/graphics/MediaPlayer.h old mode 100644
> new mode 100755
> index 993e9981..422032f
> --- a/Source/WebCore/platform/graphics/MediaPlayer.h
> +++ b/Source/WebCore/platform/graphics/MediaPlayer.h
> @@ -68,7 +68,7 @@ class MediaSource;
> // backend can live at runtime.
> struct PlatformMedia {
>      enum {
> -        None,
> +        PlayerTypeNone,
>          QTMovieType,
>          QTMovieGWorldType,
>          QTMovieVisualContextType,
> @@ -332,7 +332,7 @@ public:
>      enum MovieLoadType { Unknown, Download, StoredStream, LiveStream };
>      MovieLoadType movieLoadType() const;
> -    enum Preload { None, MetaData, Auto };
> +    enum Preload { PreloadNone, MetaData, Auto };
>      Preload preload() const;
>      void setPreload(Preload);
> diff --git
> a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cp
> p
> b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cp
> p old mode 100644
> new mode 100755
> index a4d4745..20a50a4
> ---
> a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cp
> p +++
> b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cp
> p @@ -305,7 +305,7 @@ void MediaPlayerPrivateGStreamer::load(const String&
> url) LOG_MEDIA_MESSAGE("Load %s", cleanUrl.utf8().data());
> -    if (m_preload == MediaPlayer::None) {
> +    if (m_preload == MediaPlayer::PreloadNone) {
>          LOG_MEDIA_MESSAGE("Delaying load.");
>          m_delayingLoad = true;
>      }
> @@ -1236,7 +1236,7 @@ void MediaPlayerPrivateGStreamer::updateStates()
>          // can't work so disable on-disk buffering and reset the
>          // pipeline.
>          if (state == GST_STATE_READY && isLiveStream() && m_preload ==
> MediaPlayer::Auto) { -            setPreload(MediaPlayer::None);
> +            setPreload(MediaPlayer::PreloadNone);
>              gst_element_set_state(m_playBin, GST_STATE_NULL);
>              gst_element_set_state(m_playBin, GST_STATE_PAUSED);
>          }
> @@ -1483,7 +1483,7 @@ void MediaPlayerPrivateGStreamer::durationChanged()
>      if (previousDuration && m_mediaDuration != previousDuration)
>          m_player->durationChanged();
> -    if (m_preload == MediaPlayer::None &&
> m_originalPreloadWasAutoAndWasOverridden) { +    if (m_preload ==
> MediaPlayer::PreloadNone && m_originalPreloadWasAutoAndWasOverridden) {
> m_totalBytes = -1;
>          if (totalBytes() && !isLiveStream()) {
>              setPreload(MediaPlayer::Auto);
> @@ -1749,7 +1749,7 @@ void
> MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload)
> g_object_set(m_playBin, "flags", flags & ~GST_PLAY_FLAG_DOWNLOAD, NULL); }
> -    if (m_delayingLoad && m_preload != MediaPlayer::None) {
> +    if (m_delayingLoad && m_preload != MediaPlayer::PreloadNone) {
>          m_delayingLoad = false;
>          commitLoad();
>      }
> diff --git a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
> b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm index
> f774040..b813671 100644
> --- a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
> +++ b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
> @@ -655,7 +655,7 @@ void MediaPlayerPrivateQTKit::load(const String& url)
>      m_movieURL = url;
>      // If the element is not supposed to load any data return immediately.
> -    if (m_preload == MediaPlayer::None)
> +    if (m_preload == MediaPlayer::PreloadNone)
>          return;
>      loadInternal(url);
> @@ -1696,7 +1696,7 @@ MediaPlayer::MovieLoadType
> MediaPlayerPrivateQTKit::movieLoadType() const void
> MediaPlayerPrivateQTKit::setPreload(MediaPlayer::Preload preload) {
>      m_preload = preload;
> -    if (m_preload == MediaPlayer::None)
> +    if (m_preload == MediaPlayer::PreloadNone)
>          return;
>      if (!m_qtMovie)
> diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
> b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp old mode
> 100644
> new mode 100755
> index 9ec765c..5288f74
> --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
> +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
> @@ -166,7 +166,7 @@ void MediaPlayerPrivateQt::load(const String& url)
>      // QtMultimedia does not have an API to throttle loading
>      // so we handle this ourselves by delaying the load
> -    if (m_preload == MediaPlayer::None) {
> +    if (m_preload == MediaPlayer::PreloadNone) {
>          m_delayingLoad = true;
>          return;
>      }
> @@ -375,7 +375,7 @@ unsigned MediaPlayerPrivateQt::totalBytes() const
> void MediaPlayerPrivateQt::setPreload(MediaPlayer::Preload preload)
> {
>      m_preload = preload;
> -    if (m_delayingLoad && m_preload != MediaPlayer::None)
> +    if (m_delayingLoad && m_preload != MediaPlayer::PreloadNone)
>          resumeLoad();
> }
> diff --git
> a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualCon
> text.cpp
> b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualCon
> text.cpp old mode 100644
> new mode 100755
> index 35c3d77..30d749d
> ---
> a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualCon
> text.cpp +++
> b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualCon
> text.cpp @@ -340,7 +340,7 @@ void
> MediaPlayerPrivateQuickTimeVisualContext::load(const String& url) {
>      m_movieURL = url;
> -    if (m_preload == MediaPlayer::None) {
> +    if (m_preload == MediaPlayer::PreloadNone) {
>          m_delayingLoad = true;
>          return;
>      }
> @@ -1058,7 +1058,7 @@ bool
> MediaPlayerPrivateQuickTimeVisualContext::hasSingleSecurityOrigin() const
> void
> MediaPlayerPrivateQuickTimeVisualContext::setPreload(MediaPlayer::Preload
> preload) {
>      m_preload = preload;
> -    if (m_delayingLoad && m_preload != MediaPlayer::None)
> +    if (m_delayingLoad && m_preload != MediaPlayer::PreloadNone)
>          resumeLoad();
> }
> diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
> b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp index d2461a9..d345a60
> 100644
> --- a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
> +++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
> @@ -393,7 +393,7 @@
> COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::MovieLoadTypeDownload,
> MediaPlayer:
> COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::MovieLoadTypeStoredStream,
> MediaPlayer::StoredStream);
> COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::MovieLoadTypeLiveStream,
> MediaPlayer::LiveStream);
> -COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadNone,
> MediaPlayer::None);
> +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadNone,
> MediaPlayer::PreloadNone);
> COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadMetaData,
> MediaPlayer::MetaData);
> COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadAuto,
> MediaPlayer::Auto); diff --git
> a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
> b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index
> e75c739..217f87d 100644
> --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
> +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
> @@ -315,7 +315,7 @@ void WebMediaPlayerClientImpl::load(const String& url)
>      m_url = url;
>      MutexLocker locker(m_webMediaPlayerMutex);
> -    if (m_preload == MediaPlayer::None) {
> +    if (m_preload == MediaPlayer::PreloadNone) {
> #if ENABLE(WEB_AUDIO)
>          m_audioSourceProvider.wrap(0); // Clear weak reference to
> m_webMediaPlayer's WebAudioSourceProvider. #endif
> @@ -686,7 +686,7 @@ void
> WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload) if
> (m_webMediaPlayer)
>         
> m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preload))
> ; -    if (m_delayingLoad && m_preload != MediaPlayer::None)
> +    if (m_delayingLoad && m_preload != MediaPlayer::PreloadNone)
>          startDelayedLoad();
> }
> --
> 1.7.9.5
> 
> 
> From: webkit-dev-bounces at lists.webkit.org
> [mailto:webkit-dev-bounces at lists.webkit.org] On Behalf Of Zhao, Halley
> Sent: Thursday, November 08, 2012 6:00 PM
> To: webkit-dev at lists.webkit.org
> Subject: [webkit-dev] compile failure when I try to introduce GLContextEGL
> to MediaPlayerPrivateGStreamer
> 
> Hi experts:
> I want to introduce EGL context to GStreamer Media player
> (MediaPlayerPrivateGStreamer), However, a simple '#include
> "GLContextEGL.h"' in MediaPlayerPrivateGStreamer.cpp fail to compile.
> "MediaPlayerPrivateGStreamer.cpp:321:35: error: expected unqualified-id
> before numeric constant" It seems to be namespace issue, but I can't know
> where break.
> Could you kindly educate me how to do it?
> 
> Thanks.
> More backgrounds see here:
> https://bugs.webkit.org/show_bug.cgi?id=86410


More information about the webkit-dev mailing list