[xiph-commits] r17472 - in trunk/oggdsf/src/lib/plugin/AxPlayer: . Res

cristianadam at svn.xiph.org cristianadam at svn.xiph.org
Sun Sep 26 23:07:32 PDT 2010


Author: cristianadam
Date: 2010-09-26 23:07:32 -0700 (Sun, 26 Sep 2010)
New Revision: 17472

Added:
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/error.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/muteButton.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/pauseButton.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/playButton.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/positionThumb.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/throbber.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/unmuteButton.png
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/volumeThumb.png
Modified:
   trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj
   trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl
   trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp
   trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h
   trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp
   trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.h
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/AxPlayer.rc
   trunk/oggdsf/src/lib/plugin/AxPlayer/Res/resource.h
   trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp
   trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h
Log:
Added basic controls. Play/pause, mute/unmute and position/duration display works.

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj	2010-09-27 06:07:32 UTC (rev 17472)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1250"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8.00"
+	Version="8,00"
 	Name="AxPlayer"
 	ProjectGUID="{C2C1F096-2541-4B13-A57E-52F2368A0E36}"
 	RootNamespace="AxPlayer"
@@ -81,7 +81,7 @@
 				Name="VCLinkerTool"
 				RegisterOutput="true"
 				IgnoreImportLibrary="true"
-				AdditionalDependencies="ddraw.lib d3d9.lib "
+				AdditionalDependencies="ddraw.lib d3d9.lib gdiplus.lib"
 				LinkIncremental="2"
 				ModuleDefinitionFile=".\AxPlayer.def"
 				GenerateDebugInformation="true"
@@ -174,7 +174,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				IgnoreImportLibrary="true"
-				AdditionalDependencies="ddraw.lib d3d9.lib"
+				AdditionalDependencies="ddraw.lib d3d9.lib gdiplus.lib"
 				LinkIncremental="2"
 				ModuleDefinitionFile=".\AxPlayer.def"
 				GenerateDebugInformation="true"
@@ -270,7 +270,7 @@
 				Name="VCLinkerTool"
 				RegisterOutput="true"
 				IgnoreImportLibrary="true"
-				AdditionalDependencies="ddraw.lib d3d9.lib"
+				AdditionalDependencies="ddraw.lib d3d9.lib gdiplus.lib"
 				LinkIncremental="1"
 				ModuleDefinitionFile=".\AxPlayer.def"
 				GenerateDebugInformation="true"
@@ -366,7 +366,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				IgnoreImportLibrary="true"
-				AdditionalDependencies="ddraw.lib d3d9.lib"
+				AdditionalDependencies="ddraw.lib d3d9.lib gdiplus.lib"
 				LinkIncremental="1"
 				ModuleDefinitionFile=".\AxPlayer.def"
 				GenerateDebugInformation="true"
@@ -626,11 +626,11 @@
 				>
 			</File>
 			<File
-				RelativePath=".\Res\VideoTagBehavior.rgs"
+				RelativePath=".\VideoTagBehavior.rgs"
 				>
 			</File>
 			<File
-				RelativePath=".\VideoTagBehavior.rgs"
+				RelativePath=".\Res\VideoTagBehavior.rgs"
 				>
 			</File>
 		</Filter>

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl	2010-09-27 06:07:32 UTC (rev 17472)
@@ -36,7 +36,9 @@
 ]
 interface IEmbeddedAxEventsSink : IUnknown{
 
-    [helpstring("method OnLeftButtonDown")] HRESULT OnLeftButtonDown(LONG x, LONG y);
+    [helpstring("method OnMouseLeftButtonDown")] HRESULT OnEmbeddedLButtonDown(LONG x, LONG y);
+    [helpstring("method OnMouseLeftButtonDown")] HRESULT OnEmbeddedLButtonUp(LONG x, LONG y);
+    [helpstring("method OnMouseMove")] HRESULT OnEmbeddedMouseMove(LONG x, LONG y);
     [helpstring("method OnEmbeddedDraw")] HRESULT OnEmbeddedDraw(RECT rect, HDC hdc);
 };
 [

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp	2010-09-27 06:07:32 UTC (rev 17472)
@@ -34,24 +34,56 @@
 #include <ddraw.h>
 #include "DDrawUtil.h"
 #include "DShowUtil.h"
+#include "resource.h"
 
+namespace 
+{
+    const int CONTROLS_HEIGHT = 28;
+
+    const Gdiplus::Color CONTROLS_BACKGROUND_COLOR = Gdiplus::Color((BYTE)(0.74 * 256), 35, 31, 32);
+    const Gdiplus::Color TEXT_COLOR = Gdiplus::Color((BYTE)(0.75 * 256), 255, 255, 255);
+
+    const int UPDATE_DURATION = 1;
+}
+
 DShowVideoPlayer::DShowVideoPlayer() :
 m_isFirstFrame(false),
 m_executeFunctionOnThread(0),
 m_playerCallback(0),
 m_state(NotOpened),
-m_textureFilterType(D3DTEXF_NONE)
+m_audioState(UnMuted),
+m_textureFilterType(D3DTEXF_NONE),
+m_isMouseOver(false),
+m_audioVolume(FilterGraph::MIN_VOLUME),
+m_duration(0),
+m_position(0)
 {
     m_stopPlaybackEvent = ::CreateEvent(0, FALSE, FALSE, 0);
     m_executeFunctionEvent = ::CreateEvent(0 , FALSE, FALSE, 0);
 
     m_d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+
+    Gdiplus::GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, 0);
+
+    m_pngPlay = LoadImage(IDI_PNG_PLAY);
+    m_pngPause = LoadImage(IDI_PNG_PAUSE);
+    m_pngMute = LoadImage(IDI_PNG_MUTE);
+    m_pngUnmute = LoadImage(IDI_PNG_UNMUTE);
+    m_pngPositionThumb = LoadImage(IDI_PNG_POSITION_THUMB);
 }
 
 DShowVideoPlayer::~DShowVideoPlayer()
 {
     ::CloseHandle(m_stopPlaybackEvent);
     ::CloseHandle(m_executeFunctionEvent);
+
+    delete m_pngPlay;
+    delete m_pngPause;
+    delete m_pngMute;
+    delete m_pngUnmute;
+    delete m_pngPositionThumb;
+
+    Gdiplus::GdiplusShutdown(m_gdiplusToken);
 }
 
 void DShowVideoPlayer::CreateBackBufferSurface(const CSize& videoSize)
@@ -144,6 +176,7 @@
             D3DPOOL_SYSTEMMEM, &m_presentBuffer, 0));
 
         m_scalingSize = aSize;
+        CreateControls(m_scalingSize);
     }
 
     return m_scalingBuffer;
@@ -196,6 +229,8 @@
                 break;
             }
 
+            DrawControls(rect, presentBufferDC);
+
             ::BitBlt(hdc, rect.left, rect.top, rect.Width(), rect.Height(), presentBufferDC, 0, 0, SRCCOPY);
 
             CHECK_HR(m_presentBuffer->ReleaseDC(presentBufferDC));
@@ -266,6 +301,14 @@
     return S_OK;
 }
 
+HRESULT DShowVideoPlayer::Mute()
+{
+    m_executeFunctionOnThread = &DShowVideoPlayer::Thread_Mute;
+    ::SetEvent(m_executeFunctionEvent);
+
+    return S_OK;
+}
+
 void DShowVideoPlayer::InitializePlaybackThread()
 {
     unsigned int threadId;
@@ -290,6 +333,12 @@
     m_filterGraph.BuildGraph(GetSrc());
     
     m_filterGraph.Pause();
+
+    if (m_filterGraph.GetVolume() == FilterGraph::MIN_VOLUME)
+    {
+        m_audioState = Muted;
+    }
+
     m_state = Paused;
 }
 
@@ -371,12 +420,15 @@
     {
         CSize videoSize = GetSurfaceSize(frame->lpSurf);
         CreateBackBufferSurface(videoSize);
+        CreateControls(videoSize);
 
         if (m_playerCallback)
         {
             m_playerCallback->MovieSize(videoSize);
         }
         m_isFirstFrame = false;
+
+        SetTimer(UPDATE_DURATION, 1000);
     }
 
     if (!m_backBuffer)
@@ -412,7 +464,31 @@
     m_filterGraph.Stop();
 }
 
+void DShowVideoPlayer::Thread_Mute()
+{
+    long currentVolume = m_filterGraph.GetVolume();
+    if (m_audioState == DShowVideoPlayer::UnMuted)
+    {
+        m_audioVolume = currentVolume;
+        m_filterGraph.SetVolume(FilterGraph::MIN_VOLUME);
 
+        m_audioState = DShowVideoPlayer::Muted;
+    }
+    else
+    {
+        m_filterGraph.SetVolume(m_audioVolume);
+        m_audioState = DShowVideoPlayer::UnMuted;
+    }
+}
+
+
+void DShowVideoPlayer::Thread_DurationPosition()
+{
+    m_duration = m_filterGraph.GetDuration();
+    m_position = m_filterGraph.GetPosition();
+}
+
+
 void DShowVideoPlayer::Thread_ExecuteFunction()
 {
     if (m_executeFunctionOnThread)
@@ -435,3 +511,217 @@
 {
     return m_state;
 }
+
+
+DShowVideoPlayer::AudioState DShowVideoPlayer::GetAudioState() const
+{
+    return m_audioState;
+}
+
+void DShowVideoPlayer::CreateControls(const CSize& videoSize)
+{
+    m_playButtonRect.SetRect(0, videoSize.cy - CONTROLS_HEIGHT, CONTROLS_HEIGHT, videoSize.cy);
+    m_muteButtonRect.SetRect(videoSize.cx - CONTROLS_HEIGHT, videoSize.cy - CONTROLS_HEIGHT,
+        videoSize.cx, videoSize.cy);
+}
+
+void DShowVideoPlayer::DrawControls(const CRect& rect, HDC dc)
+{
+    if (!GetMouseOver())
+    {
+        return;
+    }
+
+    using namespace Gdiplus;
+    Graphics graphics(dc);
+    graphics.SetInterpolationMode(InterpolationModeHighQuality);
+
+    // Draw the background
+    SolidBrush brush(CONTROLS_BACKGROUND_COLOR);
+    graphics.FillRectangle(&brush, 0, rect.Height() - CONTROLS_HEIGHT, rect.Width(), CONTROLS_HEIGHT);
+
+    // Draw the play/pause button
+    if (GetState() == DShowVideoPlayer::Paused ||
+        GetState() == DShowVideoPlayer::Stopped)
+    {
+        graphics.DrawImage(m_pngPlay, 0, rect.Height() - CONTROLS_HEIGHT, CONTROLS_HEIGHT, CONTROLS_HEIGHT);
+    }
+    else if (GetState() == DShowVideoPlayer::Playing)
+    {
+        graphics.DrawImage(m_pngPause, 0, rect.Height() - CONTROLS_HEIGHT, CONTROLS_HEIGHT, CONTROLS_HEIGHT);
+    }
+
+    // Draw the mute/unmute button
+    if (GetAudioState() == DShowVideoPlayer::UnMuted)
+    {
+        graphics.DrawImage(m_pngMute, rect.Width() - CONTROLS_HEIGHT, rect.Height() - CONTROLS_HEIGHT, 
+            CONTROLS_HEIGHT, CONTROLS_HEIGHT);
+    }
+    else
+    {
+        graphics.DrawImage(m_pngUnmute, rect.Width() - CONTROLS_HEIGHT, rect.Height() - CONTROLS_HEIGHT, 
+            CONTROLS_HEIGHT, CONTROLS_HEIGHT);
+    }
+
+    // Draw the duration
+    CString durationText;
+
+    if ((m_position / 1000) / 3600 == 0)
+    {
+        durationText.Format(L"%d:%.2d / %d:%.2d", 
+            (m_position / 1000) / 60, (m_position / 1000) % 60,
+            (m_duration / 1000) / 60, (m_duration / 1000) % 60);
+    }
+    else
+    {
+        durationText.Format(L"%d%.2d:%.2d / %d:%.2d:%.2d", 
+            (m_position / 1000) / 3600, ((m_position / 1000) % 3600) / 60, ((m_position / 1000) % 3600) % 60,
+            (m_duration / 1000) / 3600, ((m_duration / 1000) % 3600) / 60, ((m_duration / 1000) % 3600) % 60);
+    }
+
+    Font durationFont(L"Arial", 9);
+    SolidBrush durationBrush(TEXT_COLOR);
+
+    RectF durationRect(rect.Width() - CONTROLS_HEIGHT - 65, rect.Height() - CONTROLS_HEIGHT, 
+        65, CONTROLS_HEIGHT);
+
+    const StringFormat* durationStringFormat = StringFormat::GenericDefault();
+
+    RectF measuredBox;
+    graphics.MeasureString(durationText, -1, &durationFont, durationRect, &measuredBox);
+
+    durationRect.X = rect.Width() - CONTROLS_HEIGHT - measuredBox.Width;
+    durationRect.Y = rect.Height() - CONTROLS_HEIGHT + (CONTROLS_HEIGHT - measuredBox.Height) / 2;
+    durationRect.Width  = measuredBox.Width;
+    durationRect.Height = measuredBox.Height;
+
+    graphics.DrawString(durationText, -1, &durationFont, durationRect, durationStringFormat, &durationBrush);
+
+    // Draw the position
+    long positionSliderWidth = rect.Width() - CONTROLS_HEIGHT - CONTROLS_HEIGHT - durationRect.Width - 
+                                m_pngPositionThumb->GetWidth() - 10;
+
+    long positionThumb = CONTROLS_HEIGHT;
+    if (m_duration)
+    {
+        positionThumb += (long)(((float)m_position / m_duration) * positionSliderWidth);
+    }
+
+    SolidBrush colorPlayed(Color(192, 255, 255, 255));
+    graphics.FillRectangle(&colorPlayed, CONTROLS_HEIGHT, rect.Height() - CONTROLS_HEIGHT + 9, 
+        positionThumb - CONTROLS_HEIGHT, 10);
+
+    SolidBrush colorToBePlayed(Color(128, 255, 255, 255));
+    graphics.FillRectangle(&colorToBePlayed, positionThumb, rect.Height() - CONTROLS_HEIGHT + 9, 
+        positionSliderWidth - positionThumb + CONTROLS_HEIGHT + m_pngPositionThumb->GetWidth() , 10);
+
+    graphics.DrawImage(m_pngPositionThumb, positionThumb, 
+        rect.Height() - CONTROLS_HEIGHT + (CONTROLS_HEIGHT - m_pngPositionThumb->GetHeight()) / 2,
+        m_pngPositionThumb->GetWidth(), m_pngPositionThumb->GetHeight());
+}
+
+void DShowVideoPlayer::OnMouseButtonDown(long x, long y)
+{
+
+}
+
+void DShowVideoPlayer::OnMouseButtonUp(long x, long y)
+{
+    if (m_playButtonRect.PtInRect(CPoint(x, y)))
+    {
+        if (GetState() == DShowVideoPlayer::Paused ||
+            GetState() == DShowVideoPlayer::Stopped)
+        {
+            Play();
+            if (m_playerCallback)
+            {
+                m_playerCallback->Refresh();
+            }
+        }
+        else if (GetState() == DShowVideoPlayer::Playing)
+        {
+            Pause();
+            if (m_playerCallback)
+            {
+                m_playerCallback->Refresh();
+            }
+        }
+    }
+
+    if (m_muteButtonRect.PtInRect(CPoint(x, y)))
+    {
+        Mute();
+        if (m_playerCallback)
+        {
+            m_playerCallback->Refresh();
+        }
+    }
+}
+
+void DShowVideoPlayer::OnMouseMove(long x, long y)
+{
+
+}
+
+Gdiplus::Image* DShowVideoPlayer::LoadImage(UINT resourceId)
+{
+    Gdiplus::Image* image = 0;
+
+    HRSRC hResource = ::FindResource(util::GetHModule(), MAKEINTRESOURCE(resourceId), RT_RCDATA);
+    if (!hResource)
+    {
+        return image;
+    }
+
+    DWORD imageSize = ::SizeofResource(util::GetHModule(), hResource);
+    if (!imageSize)
+    {
+        image;
+    }
+
+    const void* pResourceData = ::LockResource(::LoadResource(util::GetHModule(), hResource));
+    if (!pResourceData)
+    {
+        return image;
+    }
+
+    HGLOBAL buffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
+    if (!buffer)
+    {
+        return image;
+    }
+    void* pBuffer = ::GlobalLock(buffer);
+    if (!pBuffer)
+    {
+        ::GlobalFree(buffer);
+        return image;
+    }
+    CopyMemory(pBuffer, pResourceData, imageSize);
+
+    CComPtr<IStream> pStream = NULL;
+    if (::CreateStreamOnHGlobal(buffer, FALSE, &pStream) == S_OK)
+    {
+        image = Gdiplus::Bitmap::FromStream(pStream);
+    }
+    ::GlobalUnlock(buffer);
+    ::GlobalFree(buffer);
+
+    return image;
+}
+
+LRESULT DShowVideoPlayer::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    if (wParam == UPDATE_DURATION)
+    {
+        m_executeFunctionOnThread = &DShowVideoPlayer::Thread_DurationPosition;
+        ::SetEvent(m_executeFunctionEvent);
+    }
+
+    return 0;
+}
+
+LRESULT DShowVideoPlayer::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    KillTimer(UPDATE_DURATION);
+    return 0;
+}

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h	2010-09-27 06:07:32 UTC (rev 17472)
@@ -35,6 +35,7 @@
 #pragma once
 
 #include <atlwin.h>
+#include <gdiplus.h>
 #include "FilterGraph.h"
 
 class DShowVideoPlayerCallback
@@ -54,6 +55,8 @@
 
     BEGIN_MSG_MAP(DShowVideoPlayer)
         MESSAGE_HANDLER(WM_PRESENT_IMAGE, OnPresentImage)
+        MESSAGE_HANDLER(WM_TIMER, OnTimer)
+        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
     END_MSG_MAP()
 
     enum PlayerState
@@ -64,7 +67,15 @@
         Stopped,
     };
 
+    enum AudioState
+    {
+        Muted,
+        UnMuted
+    };
+
     LRESULT OnPresentImage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
     HRESULT Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject);
 
     int GetWidth() const;
@@ -87,14 +98,26 @@
     HRESULT Pause();
     HRESULT Stop();
 
+    HRESULT Mute();
+
     DShowVideoPlayer::PlayerState GetState() const;
+    DShowVideoPlayer::AudioState GetAudioState() const;
 
+    bool GetMouseOver() const { return m_isMouseOver; }
+    void SetMouseOver(bool val) { m_isMouseOver = val; }
+
+    void OnMouseButtonDown(long x, long y);
+    void OnMouseButtonUp(long x, long y);
+    void OnMouseMove(long x, long y);
+
 private:
     void Thread_PrepareGraph();
 
     void Thread_Play();
     void Thread_Pause();
     void Thread_Stop();
+    void Thread_Mute();
+    void Thread_DurationPosition();
 
     void Thread_ExecuteFunction();
     
@@ -102,9 +125,14 @@
     CSize GetSurfaceSize(const CComPtr<IDirect3DSurface9>& surface);
     CComPtr<IDirect3DSurface9>& GetScalingSurface(const CSize &aSize);
 
+    void CreateControls(const CSize& videoSize);
+    void DrawControls(const CRect& rect, HDC dc);
+
     void CreateDevice();
     CComPtr<IDirect3DDevice9>& GetDevice();
 
+    Gdiplus::Image* LoadImage(UINT resourceId);
+
 private:
     FilterGraph m_filterGraph;
 
@@ -124,6 +152,15 @@
     HANDLE m_stopPlaybackEvent;
     HANDLE m_executeFunctionEvent;
 
+    Gdiplus::GdiplusStartupInput m_gdiplusStartupInput;
+    ULONG_PTR m_gdiplusToken;
+
+    Gdiplus::Image* m_pngPlay;
+    Gdiplus::Image* m_pngPause;
+    Gdiplus::Image* m_pngMute;
+    Gdiplus::Image* m_pngUnmute;
+    Gdiplus::Image* m_pngPositionThumb;
+
     DShowVideoPlayerCallback* m_playerCallback;
 
     typedef void (DShowVideoPlayer::* ExecuteFunctionOnThread)();
@@ -131,7 +168,17 @@
 
     bool m_isFirstFrame;
     PlayerState m_state;
+    AudioState m_audioState;
 
+    bool m_isMouseOver;
+    CRect m_playButtonRect;
+    CRect m_muteButtonRect;
+
+    long m_audioVolume;
+
+    unsigned long m_duration;
+    unsigned long m_position;
+
     D3DTEXTUREFILTERTYPE m_textureFilterType;
 };
 

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp	2010-09-27 06:07:32 UTC (rev 17472)
@@ -90,6 +90,7 @@
 
         CHECK_HR(m_graphBuilder.QueryInterface(&m_mediaControl));
         CHECK_HR(m_graphBuilder.QueryInterface(&m_mediaEvent));
+        CHECK_HR(m_graphBuilder.QueryInterface(&m_mediaSeeking));
 
         LOG(logINFO) << __FUNCTIONW__ << " Graph was successfully build.";
     }
@@ -193,7 +194,9 @@
     // Add audio renderer
     m_audioRenderer = DShowUtil::AddFilterFromCLSID(m_graphBuilder, CLSID_DSoundRender, 
                                                     L"DirectSound Renderer");
-    
+
+    m_audioRenderer->QueryInterface(&m_basicAudio);
+
     // Add video renderer
     m_videoRenderer = DShowUtil::AddFilterFromCLSID(m_graphBuilder, CLSID_VideoMixingRenderer9,
                                                     L"Video Mixing Renderer 9");
@@ -396,3 +399,86 @@
 {
     m_d3d = val;
 }
+
+long FilterGraph::GetVolume() const
+{
+    if (!m_haveAudio)
+    {
+        return MIN_VOLUME;
+    }
+
+    if (!m_basicAudio)
+    {
+        return MIN_VOLUME;
+    }
+
+    long volume = MIN_VOLUME;
+    try
+    {
+        CHECK_HR(m_basicAudio->get_Volume(&volume));
+    }
+    catch (const CAtlException& except)
+    {
+        LOG(logERROR) << __FUNCTIONW__ << " Error code: " << std::hex << except.m_hr;
+    }
+
+    return volume;
+}
+
+void FilterGraph::SetVolume(long vol)
+{
+    if (!m_haveAudio)
+    {
+        return;
+    }
+
+    if (!m_basicAudio)
+    {
+        return;
+    }
+
+    try
+    {
+        CHECK_HR(m_basicAudio->put_Volume(vol));
+    }
+    catch (const CAtlException& except)
+    {
+        LOG(logERROR) << __FUNCTIONW__ << " Error code: " << std::hex << except.m_hr;
+    }
+}
+
+unsigned long FilterGraph::GetDuration() const
+{
+    unsigned long duration = 0;
+    try
+    {
+        REFERENCE_TIME rtDuration = 0;
+        CHECK_HR(m_mediaSeeking->GetDuration(&rtDuration));
+
+        duration = rtDuration / 10000;
+    }
+    catch (const CAtlException& except)
+    {
+        LOG(logERROR) << __FUNCTIONW__ << " Error code: " << std::hex << except.m_hr;
+    }
+
+    return duration;
+}
+
+unsigned long FilterGraph::GetPosition() const
+{
+    unsigned long position = 0;
+    try
+    {
+        REFERENCE_TIME rtCurrentPosition = 0;
+        CHECK_HR(m_mediaSeeking->GetCurrentPosition(&rtCurrentPosition));
+
+        position = rtCurrentPosition / 10000;
+    }
+    catch (const CAtlException& except)
+    {
+        LOG(logERROR) << __FUNCTIONW__ << " Error code: " << std::hex << except.m_hr;
+    }
+
+    return position;
+}

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.h	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.h	2010-09-27 06:07:32 UTC (rev 17472)
@@ -68,6 +68,14 @@
     HANDLE GetMovieEventHandle();
     long GetMovieEventCode();
 
+    long GetVolume() const;
+    void SetVolume(long vol);
+
+    unsigned long GetDuration() const;
+    unsigned long GetPosition() const;
+
+    static const long MIN_VOLUME = -10000;
+
 private:
     void AddSourceDemuxFilters();
     void AddDecoders();
@@ -88,12 +96,15 @@
 
     CComPtr<IBaseFilter> m_audioRenderer;
     CComPtr<IBaseFilter> m_videoRenderer;
+    CComPtr<IBasicAudio> m_basicAudio;
 
     CComPtr<IVMRSurfaceAllocatorNotify9> m_surfaceNotify;
     CComObject<CustomVMR9Allocator>* m_customVmrAllocator;
 
     CComPtr<IMediaControl> m_mediaControl;
     CComPtr<IMediaEvent> m_mediaEvent;
+
+    CComPtr<IMediaSeeking> m_mediaSeeking;
     
     HWND m_notifyWindow;
     int m_presentImageMessage;

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/AxPlayer.rc
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/Res/AxPlayer.rc	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/Res/AxPlayer.rc	2010-09-27 06:07:32 UTC (rev 17472)
@@ -99,6 +99,15 @@
 
 IDR_AXPLAYER            REGISTRY                "AxPlayer.rgs"
 
+IDI_PNG_ERROR                   RCDATA "res\\error.png"
+IDI_PNG_MUTE                    RCDATA "res\\muteButton.png"
+IDI_PNG_UNMUTE                  RCDATA "res\\unmuteButton.png"
+IDI_PNG_PAUSE                   RCDATA "res\\pauseButton.png"
+IDI_PNG_PLAY                    RCDATA "res\\playButton.png"
+IDI_PNG_THROBBER                RCDATA "res\\throbber.png"
+IDI_PNG_VOLUME_THUMB            RCDATA "res\\volumeThumb.png"
+IDI_PNG_POSITION_THUMB          RCDATA "res\\positionThumb.png"
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // String Table

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/error.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/error.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/muteButton.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/muteButton.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/pauseButton.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/pauseButton.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/playButton.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/playButton.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/positionThumb.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/positionThumb.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/resource.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/Res/resource.h	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/Res/resource.h	2010-09-27 06:07:32 UTC (rev 17472)
@@ -12,6 +12,15 @@
 #define IDR_EVENTSINK                   110
 #define IDR_HTMLEVENTSSINK              111
 
+#define IDI_PNG_ERROR                   501
+#define IDI_PNG_MUTE                    502
+#define IDI_PNG_UNMUTE                  503
+#define IDI_PNG_PAUSE                   504
+#define IDI_PNG_PLAY                    505
+#define IDI_PNG_POSITION_THUMB          506
+#define IDI_PNG_THROBBER                507
+#define IDI_PNG_VOLUME_THUMB            508
+
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/throbber.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/throbber.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/unmuteButton.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/unmuteButton.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/volumeThumb.png
===================================================================
(Binary files differ)


Property changes on: trunk/oggdsf/src/lib/plugin/AxPlayer/Res/volumeThumb.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp	2010-09-27 06:07:32 UTC (rev 17472)
@@ -157,13 +157,12 @@
 {
     CComPtr<IDispatch> disp;
     CComPtr<IHTMLDocument2> document2;
-    CComPtr<IHTMLWindow2> window2;
 
     CHECK_HR(m_element->get_document(&disp));
     CHECK_HR(disp->QueryInterface(IID_IHTMLDocument2, (LPVOID *) &document2));
-    CHECK_HR(document2->get_parentWindow(&window2));
+    CHECK_HR(document2->get_parentWindow(&m_htmlWindow2));
 
-    CHECK_HR(window2->QueryInterface(&m_htmlWindow3));
+    CHECK_HR(m_htmlWindow2->QueryInterface(&m_htmlWindow3));
 }
 
 HRESULT __stdcall VideoTagBehavior::Detach()
@@ -385,21 +384,75 @@
     return S_OK;
 }
 
-VARIANT_BOOL __stdcall VideoTagBehavior::OnClick()
+
+VARIANT_BOOL __stdcall VideoTagBehavior::OnDHTMLMouseMove()
 {
-    if (m_videoPlayer.GetState() == DShowVideoPlayer::Paused ||
-        m_videoPlayer.GetState() == DShowVideoPlayer::Stopped)
+    if (!m_standardsMode)
     {
-        m_videoPlayer.Play();
+        CComPtr<IHTMLEventObj> event;
+        m_htmlWindow2->get_event(&event);
+
+        long x = 0;
+        long y = 0;
+        event->get_offsetX(&x);
+        event->get_offsetY(&y);
+
+        m_videoPlayer.OnMouseMove(x, y);
     }
-    else if (m_videoPlayer.GetState() == DShowVideoPlayer::Playing)
+
+    return S_OK;
+}
+
+VARIANT_BOOL __stdcall VideoTagBehavior::OnDHTMLMouseDown()
+{
+    if (!m_standardsMode)
     {
-        m_videoPlayer.Pause();
+        CComPtr<IHTMLEventObj> event;
+        m_htmlWindow2->get_event(&event);
+
+        long x = 0;
+        long y = 0;
+        event->get_offsetX(&x);
+        event->get_offsetY(&y);
+
+        m_videoPlayer.OnMouseButtonDown(x, y);
     }
 
-    return VARIANT_FALSE;
+    return S_OK;
 }
 
+VARIANT_BOOL __stdcall VideoTagBehavior::OnDHTMLMouseUp()
+{
+    if (!m_standardsMode)
+    {
+        CComPtr<IHTMLEventObj> event;
+        m_htmlWindow2->get_event(&event);
+
+        long x = 0;
+        long y = 0;
+        event->get_offsetX(&x);
+        event->get_offsetY(&y);
+
+        m_videoPlayer.OnMouseButtonUp(x, y);
+    }
+
+    return S_OK;
+}
+
+VARIANT_BOOL __stdcall VideoTagBehavior::OnDHTMLMouseOut()
+{
+    m_videoPlayer.SetMouseOver(false);
+    Refresh();
+    return S_OK;
+}
+
+VARIANT_BOOL __stdcall VideoTagBehavior::OnDHTMLMouseOver()
+{
+    m_videoPlayer.SetMouseOver(true);
+    Refresh();
+    return S_OK;
+}
+
 HRESULT __stdcall VideoTagBehavior::OnResize(SIZE pt)
 {
     LOG(logDEBUG) << __FUNCTIONW__ << ", "
@@ -630,18 +683,54 @@
 {
     if (m_embeddedAxEventsSink)
     {
-        m_embeddedAxEventsSink->OnLeftButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+        m_embeddedAxEventsSink->OnEmbeddedLButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
     }
 
     return 0;
 }
 
-HRESULT __stdcall VideoTagBehavior::OnLeftButtonDown(LONG /*x*/, LONG /*y*/)
+LRESULT VideoTagBehavior::OnLButtonUp( UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/ )
 {
-    OnClick();
+    if (m_embeddedAxEventsSink)
+    {
+        m_embeddedAxEventsSink->OnEmbeddedLButtonUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+    }
+
     return 0;
 }
 
+LRESULT VideoTagBehavior::OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
+{
+    LOG(logDEBUG) << __FUNCTIONW__ << " x: " << GET_X_LPARAM(lParam) << " y: " << GET_Y_LPARAM(lParam);
+    if (m_embeddedAxEventsSink)
+    {
+        m_embeddedAxEventsSink->OnEmbeddedMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+    }
+
+    return 0;
+}
+
+
+HRESULT __stdcall VideoTagBehavior::OnEmbeddedLButtonDown(LONG x, LONG y)
+{
+    m_videoPlayer.OnMouseButtonDown(x, y);
+    return 0;
+}
+
+
+HRESULT __stdcall VideoTagBehavior::OnEmbeddedLButtonUp(LONG x, LONG y)
+{
+    m_videoPlayer.OnMouseButtonUp(x, y);
+    return 0;
+}
+
+
+HRESULT __stdcall VideoTagBehavior::OnEmbeddedMouseMove(LONG x, LONG y)
+{
+    m_videoPlayer.OnMouseMove(x, y);
+    return 0;
+}
+
 HRESULT __stdcall VideoTagBehavior::SetEventsSink(IUnknown *events)
 {
     if (!events)

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h	2010-09-26 16:25:35 UTC (rev 17471)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h	2010-09-27 06:07:32 UTC (rev 17472)
@@ -137,11 +137,17 @@
     END_CONNECTION_POINT_MAP()
 
     BEGIN_SINK_MAP(VideoTagBehavior)
-        SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONCLICK, OnClick)
+        SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONMOUSEMOVE, OnDHTMLMouseMove)
+        SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONMOUSEDOWN, OnDHTMLMouseDown)
+        SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONMOUSEUP, OnDHTMLMouseUp)
+        SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONMOUSEOUT, OnDHTMLMouseOut)
+        SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONMOUSEOVER, OnDHTMLMouseOver)
     END_SINK_MAP()
 
     BEGIN_MSG_MAP(VideoTagBehavior)
         MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
+        MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
+        MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
         MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
         CHAIN_MSG_MAP(CComControl<VideoTagBehavior>)
         DEFAULT_REFLECTION_HANDLER()
@@ -185,7 +191,11 @@
     HRESULT __stdcall SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions);
 
     // Events
-    VARIANT_BOOL __stdcall OnClick();
+    VARIANT_BOOL __stdcall OnDHTMLMouseMove();
+    VARIANT_BOOL __stdcall OnDHTMLMouseDown();
+    VARIANT_BOOL __stdcall OnDHTMLMouseUp();
+    VARIANT_BOOL __stdcall OnDHTMLMouseOut();
+    VARIANT_BOOL __stdcall OnDHTMLMouseOver();
 
     // DShowVideoPlayerCallback
     virtual void Refresh();
@@ -201,10 +211,14 @@
 
     // ActiveX Windows Events, received only by the embedded control
     LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
+    LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
+    LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
     LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
 
     // IEmbeddedAxEventsSink
-    virtual HRESULT __stdcall OnLeftButtonDown(LONG x, LONG y);
+    virtual HRESULT __stdcall OnEmbeddedLButtonDown(LONG x, LONG y);
+    virtual HRESULT __stdcall OnEmbeddedLButtonUp(LONG x, LONG y);
+    virtual HRESULT __stdcall OnEmbeddedMouseMove(LONG x, LONG y);
     virtual HRESULT __stdcall OnEmbeddedDraw(RECT rect, HDC hdc);
 
     // IEmbeddedAx
@@ -230,6 +244,7 @@
     CComPtr<IHTMLPaintSite> m_paintSite;
     CComPtr<IHTMLElement> m_element;
     CComPtr<IOleClientSite> m_oleClientSite;
+    CComPtr<IHTMLWindow2> m_htmlWindow2;
     CComPtr<IHTMLWindow3> m_htmlWindow3;
 
     CString m_embeddedAxGuid;



More information about the commits mailing list