[Producersdk-cvs] sdksamples/previewhelperlib Umakefil, NONE, 1.1 previewhelper.cpp, NONE, 1.1 samplepreviewsink.cpp, NONE, 1.1 samplepreviewsink.h, NONE, 1.1 unix.pcf, NONE, 1.1 win.pcf, NONE, 1.1 winpreview.cpp, NONE, 1.1 winpreview.h, NONE, 1.1
hwatson at helixcommunity.org hwatson at helixcommunity.orgUpdate of /cvsroot/producersdk/sdksamples/previewhelperlib In directory cvs-new:/tmp/cvs-serv18647/previewhelperlib Added Files: Umakefil previewhelper.cpp samplepreviewsink.cpp samplepreviewsink.h unix.pcf win.pcf winpreview.cpp winpreview.h Log Message: Add preview as a lib so that it can be included in both the advencoder and mediasinkencoder sample apps. --- NEW FILE: winpreview.h --- /* ***** BEGIN LICENSE BLOCK ***** * Version: RCSL 1.0/RPSL 1.0 * * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, are * subject to the current version of the RealNetworks Public Source License * Version 1.0 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the RealNetworks Community Source License Version 1.0 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, * in which case the RCSL will apply. You may also obtain the license terms * directly from RealNetworks. You may not use this file except in * compliance with the RPSL or, if you have a valid RCSL with RealNetworks * applicable to this file, the RCSL. Please see the applicable RPSL or * RCSL for the rights, obligations and limitations governing use of the * contents of the file. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the portions * it created. * * This file, and the files included with this file, is distributed and made * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ #include "hxcom.h" #include "hxresult.h" #include "windows.h" #include "vfw.h" #ifndef _WIN_PREVIEW_H_ #define _WIN_PREVIEW_H_ class CWinPreview { public: CWinPreview(); virtual ~CWinPreview(void); HX_RESULT CreatePreviewWindow(UINT32 nPreviewIndex, short width, short height); void FreeWindow(void); void DrawVideo(const UCHAR* buffer, UINT32 size); protected: // this is the function that is registered with windows. When we create // an HWND of the CWinPreview class, we set the window long to identify // the CWinPreview instance. Then, this function can pull the value // and call the CTWinCallback_Callback() function on the owner. static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); HWND m_hWnd; HDRAWDIB m_hDrawDib; HDC m_hDC; RECT m_rectClient; BITMAPINFOHEADER m_bi; UINT32 m_nPreviewIndex; static UINT32 zm_nWindowCount; }; #endif // _WIN_PREVIEW_H_ --- NEW FILE: winpreview.cpp --- /* ***** BEGIN LICENSE BLOCK ***** * Version: RCSL 1.0/RPSL 1.0 * * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, are * subject to the current version of the RealNetworks Public Source License * Version 1.0 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the RealNetworks Community Source License Version 1.0 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, * in which case the RCSL will apply. You may also obtain the license terms * directly from RealNetworks. You may not use this file except in * compliance with the RPSL or, if you have a valid RCSL with RealNetworks * applicable to this file, the RCSL. Please see the applicable RPSL or * RCSL for the rights, obligations and limitations governing use of the * contents of the file. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the portions * it created. * * This file, and the files included with this file, is distributed and made * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ #include "winpreview.h" #include "stdio.h" #ifndef _WIN32 #define snprintf _snprintf #endif UINT32 CWinPreview::zm_nWindowCount = 0; /////////////////////////////////////////////////////////////////////// CWinPreview::CWinPreview() : m_hWnd(NULL) , m_nPreviewIndex(0) { } /////////////////////////////////////////////////////////////////////// CWinPreview::~CWinPreview(void) { FreeWindow(); } /////////////////////////////////////////////////////////////////////// LRESULT CALLBACK CWinPreview::WindowProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { CWinPreview *pThis = (CWinPreview *)::GetWindowLong(hwnd, GWL_USERDATA); return DefWindowProc(hwnd, uMsg, wParam, lParam); } /////////////////////////////////////////////////////////////////////// HX_RESULT CWinPreview::CreatePreviewWindow(UINT32 nPreviewIndex, short width, short height) { HX_RESULT res = HXR_OK; if(m_nPreviewIndex == 0) { m_nPreviewIndex = nPreviewIndex; } memset(&m_bi, 0, sizeof(m_bi)); m_bi.biSize = sizeof(m_bi); m_bi.biWidth = width; m_bi.biHeight = height; m_bi.biPlanes = 1; m_bi.biBitCount = 24;//assume RGB32 m_bi.biCompression = BI_RGB;//RGB m_bi.biSizeImage = m_bi.biWidth*m_bi.biHeight*m_bi.biBitCount/8; RECT rect; rect.top = 0; rect.left = 0; rect.bottom = m_bi.biHeight; rect.right = m_bi.biWidth; DWORD dwStyle = WS_CAPTION | WS_VISIBLE | WS_POPUPWINDOW; AdjustWindowRect(&rect, dwStyle, FALSE /* menu-present flag */); int nWndWidth = rect.right - rect.left; int nWndHeight = rect.bottom - rect.top; HINSTANCE hInstance = GetModuleHandle (NULL); HWND hWndParent = GetFocus(); WNDCLASSEX wndClassEx; // We need to set up a window class and a window for messages. wndClassEx.cbSize = sizeof(WNDCLASSEX); wndClassEx.style = 0; wndClassEx.lpfnWndProc = CWinPreview::WindowProc; wndClassEx.cbClsExtra = 0; wndClassEx.cbWndExtra = 0; wndClassEx.hInstance = NULL; wndClassEx.hIcon = NULL; wndClassEx.hCursor = NULL; wndClassEx.hbrBackground = NULL; wndClassEx.lpszMenuName = NULL; wndClassEx.lpszClassName = "CRealPreviewWindowClass"; wndClassEx.hIconSm = NULL; ATOM Class = RegisterClassEx(&wndClassEx); char szWindowName[_MAX_PATH]; _snprintf(szWindowName, _MAX_PATH, "PreviewWindow%d", m_nPreviewIndex); UINT32 nXPOS = (zm_nWindowCount % 3) * 200; UINT32 nYPOS = (zm_nWindowCount / 3) * 200; m_hWnd = CreateWindow( "CRealPreviewWindowClass", // pointer to registered class name szWindowName, // pointer to window name dwStyle, // window style nXPOS, // horizontal position of window nYPOS, // vertical position of window nWndWidth, // window width nWndHeight, // window height hWndParent, // handle to parent or owner window NULL, // handle to menu or child-window identifier hInstance, // handle to application instance NULL // pointer to window-creation data ); if (::IsWindow(m_hWnd)) { // store this on the window ::SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this); m_hDrawDib = DrawDibOpen(); m_hDC = ::GetDC(m_hWnd); ::GetClientRect(m_hWnd, &m_rectClient); BOOL bRes = DrawDibBegin(m_hDrawDib, m_hDC, m_rectClient.right, m_rectClient.bottom, &m_bi, m_bi.biWidth, m_bi.biHeight, 0); UINT32 nNumPalettes = DrawDibRealize(m_hDrawDib, m_hDC, FALSE);//not forcing background } zm_nWindowCount++; return res; } /////////////////////////////////////////////////////////////////////// void CWinPreview::FreeWindow(void) { if (::IsWindow(m_hWnd)) { int res = ReleaseDC(m_hWnd, m_hDC); BOOL bRes; bRes = DrawDibEnd(m_hDrawDib); bRes = DrawDibClose(m_hDrawDib); DestroyWindow(m_hWnd); m_hWnd = NULL; } } /////////////////////////////////////////////////////////////////////// void CWinPreview::DrawVideo(const UCHAR* pBuffer, UINT32 size) { if (::IsWindow(m_hWnd)) { BOOL bResult = ::DrawDibDraw(m_hDrawDib, m_hDC, m_rectClient.left, m_rectClient.top, m_rectClient.right - m_rectClient.left, m_rectClient.bottom - m_rectClient.top, &m_bi, (void*) pBuffer, 0, 0, m_bi.biWidth, m_bi.biHeight, 0); MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } --- NEW FILE: unix.pcf --- # # ***** BEGIN LICENSE BLOCK ***** # Version: RCSL 1.0/RPSL 1.0 # # Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. # # The contents of this file, and the files included with this file, are # subject to the current version of the RealNetworks Public Source License # Version 1.0 (the "RPSL") available at # http://www.helixcommunity.org/content/rpsl unless you have licensed # the file under the RealNetworks Community Source License Version 1.0 # (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, # in which case the RCSL will apply. You may also obtain the license terms # directly from RealNetworks. You may not use this file except in # compliance with the RPSL or, if you have a valid RCSL with RealNetworks # applicable to this file, the RCSL. Please see the applicable RPSL or # RCSL for the rights, obligations and limitations governing use of the # contents of the file. # # This file is part of the Helix DNA Technology. RealNetworks is the # developer of the Original Code and owns the copyrights in the portions # it created. # # This file, and the files included with this file, is distributed and made # available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER # EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. # # Technology Compatibility Kit Test Suite(s) Location: # http://www.helixcommunity.org/content/tck # # Contributor(s): # # ***** END LICENSE BLOCK ***** # # Note -- stlport currently disables iostreams, so use native STL libs instead project.RemoveModuleIncludes('common/import/stlport') project.sys_libraries.append('pthread', 'dl', 'm', 'c', 'stdc++') --- NEW FILE: samplepreviewsink.cpp --- /* ***** BEGIN LICENSE BLOCK ***** * Version: RCSL 1.0/RPSL 1.0 * * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, are * subject to the current version of the RealNetworks Public Source License * Version 1.0 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the RealNetworks Community Source License Version 1.0 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, * in which case the RCSL will apply. You may also obtain the license terms * directly from RealNetworks. You may not use this file except in * compliance with the RPSL or, if you have a valid RCSL with RealNetworks * applicable to this file, the RCSL. Please see the applicable RPSL or * RCSL for the rights, obligations and limitations governing use of the * contents of the file. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the portions * it created. * * This file, and the files included with this file, is distributed and made * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ #ifdef _WINDOWS #include "winpreview.h" #endif // _WINDOWS #include "samplepreviewsink.h" // standard includes #include <iostream> #include <assert.h> #include <string.h> using namespace std; CSamplePreviewSink::CSamplePreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat) : m_ulRefCount(0) , m_nPreviewPosition(nPreviewPosition) , m_nPreviewIndex(nPreviewIndex) , m_nOutputProfile(nOutputProfile) , m_nAudience(nAudience) , m_pszMediaFormat(NULL) { // store media format string UINT32 nSize = strlen(szMediaFormat) + 1; m_pszMediaFormat = new char[nSize]; strncpy(m_pszMediaFormat, szMediaFormat, nSize); } CSamplePreviewSink::~CSamplePreviewSink() { HX_VECTOR_DELETE(m_pszMediaFormat); } //IUnknown methods STDMETHODIMP_(ULONG32) CSamplePreviewSink::AddRef() { return InterlockedIncrement(&m_ulRefCount); } STDMETHODIMP_(ULONG32) CSamplePreviewSink::Release() { if (InterlockedDecrement(&m_ulRefCount) > 0) { return m_ulRefCount; } delete this; return 0; } STDMETHODIMP CSamplePreviewSink::QueryInterface( REFIID riid, void** ppvObj ) { if(!ppvObj) { return HXR_POINTER; } if(IsEqualIID(IID_IHXTPreviewSink, riid)) { AddRef(); *ppvObj = (IHXTPreviewSink*)this; return HXR_OK; } return HXR_FAIL; } CAudioPreviewSink::CAudioPreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat, INT32 nSampleRate, INT32 nSampleFormat, INT32 nChannelFormat) : CSamplePreviewSink( nPreviewPosition, nPreviewIndex, nOutputProfile, nAudience, szMediaFormat) , m_nSampleRate(nSampleRate) , m_nSampleFormat(nSampleFormat) , m_nChannelFormat(nChannelFormat) { assert( strcmp(szMediaFormat, kValueMediaFormatUncompAudio ) == 0 ); } CAudioPreviewSink::~CAudioPreviewSink() { } STDMETHODIMP CAudioPreviewSink::OnFormatChanged(IHXTPropertyBag* pProps) { assert(strcmp(m_pszMediaFormat, kValueMediaFormatUncompAudio) == 0); pProps->GetUint(kPropAudioSampleRate, &m_nSampleRate); pProps->GetUint(kPropAudioSampleFormat, &m_nSampleFormat); pProps->GetUint(kPropAudioChannelFormat, &m_nChannelFormat); fprintf(stdout, "Preview %s:%d: OnFormatChanged(samplerate=%d, sampleformat=%d, channelformat=%d)\n", m_pszMediaFormat, m_nPreviewIndex, m_nSampleRate, m_nSampleFormat, m_nChannelFormat); return HXR_OK; } STDMETHODIMP CAudioPreviewSink::OnSample(IHXTMediaSample* pSample) { assert(pSample); if(pSample) { // get sample time HXT_TIME tmStart = 0; HXT_TIME tmEnd = 0; pSample->GetTime(&tmStart, &tmEnd); assert(tmStart<=tmEnd); // print sample time printf("CAudioPreviewSink::OnSample %s:%d: Start %ld, End %ld\n", m_pszMediaFormat, m_nPreviewIndex, (INT32) tmStart, (INT32) tmEnd); return HXR_OK; } return HXR_FAIL; } CAudioLevelPreviewSink::CAudioLevelPreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat, INT32 nSampleRate, INT32 nSampleFormat, INT32 nChannelFormat) : CAudioPreviewSink( nPreviewPosition, nPreviewIndex, nOutputProfile, nAudience, szMediaFormat, nSampleRate, nSampleFormat, nChannelFormat ) { assert( strcmp(szMediaFormat, kValueMediaFormatUncompAudio ) == 0 ); } CAudioLevelPreviewSink::~CAudioLevelPreviewSink() { } STDMETHODIMP CAudioLevelPreviewSink::OnFormatChanged(IHXTPropertyBag* pProps) { return CAudioPreviewSink::OnFormatChanged(pProps); } STDMETHODIMP CAudioLevelPreviewSink::OnSample(IHXTMediaSample* pSample) { assert(pSample); if(pSample) { // if audio control is defined and sample has audio level data HX_RESULT res = HXR_FAIL; IHXTAudioLevelChannelsPtr spAudioLevels; if ( SUCCEEDED(spAudioLevels.Query(pSample))) { // get channel count IHXTAudioLevelChannelPtr spChannel; UINT32 uChannelCount = min( spAudioLevels->GetChannelCount(), (UINT32) 2 ); // extract left and right channels, if present float fLeft = 0.0, fRight = 0.0; float fLeftPeak = 0.0, fRightPeak = 0.0; float fLeftPeakHold = 0.0, fRightPeakHold = 0.0; switch (uChannelCount) { // extract right channel if present case 2: // get channel res = spAudioLevels->GetChannel(1, spChannel.Adopt()); if (FAILED(res)) { break; } // get level data fRight = spChannel->GetEnergy(); fRightPeak = spChannel->GetPeak(); fRightPeakHold = spChannel->GetPeakHold(); // extract left channel, if present case 1: // get channel res = spAudioLevels->GetChannel(0, spChannel.Adopt()); if (FAILED(res)) { break; } // get level data fLeft = spChannel->GetEnergy(); fLeftPeak = spChannel->GetPeak(); fLeftPeakHold = spChannel->GetPeakHold(); break; case 0: assert("No audio level data detected!" == NULL); }; // print left and right volume levels printf("CAudioLevelPreviewSink::OnSample Left %f, Right %g\n", fLeft, fRight); return HXR_OK; } } assert( "Failed to retrieve audio level data!" == NULL ); return HXR_FAIL; } CVideoPreviewSink::CVideoPreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat, UINT32 nColorFormat, UINT32 nVideoWidth, UINT32 nVideoHeight) : CSamplePreviewSink( nPreviewPosition, nPreviewIndex, nOutputProfile, nAudience, szMediaFormat ) , m_nColorFormat(nColorFormat) #ifdef _WIN32 , m_pWinPreview(NULL) #endif { assert( strcmp(szMediaFormat, kValueMediaFormatUncompVideo ) == 0 ); if(strcmp(szMediaFormat, kValueMediaFormatUncompVideo) == 0) { if(m_nColorFormat == HXT_VIDEO_FORMAT_BGR24_INVERTED || m_nColorFormat == HXT_VIDEO_FORMAT_BGR24_NONINVERTED) { #ifdef _WIN32 m_pWinPreview = new CWinPreview(); if(m_pWinPreview) { m_pWinPreview->CreatePreviewWindow(nPreviewIndex, nVideoWidth, nVideoHeight); } #endif } else { fprintf(stderr, "INFORMATIONAL: Unable to create the video preview window. The format must be RGB24 or RGB24 Inverted to display in the video window.\n"); } } } CVideoPreviewSink::~CVideoPreviewSink() { #ifdef _WIN32 HX_DELETE(m_pWinPreview); #endif } // IHXTPreviewSink methods STDMETHODIMP CVideoPreviewSink::OnFormatChanged(IHXTPropertyBag* pProps) { assert(strcmp(m_pszMediaFormat, kValueMediaFormatUncompVideo) == 0); HX_RESULT res = HXR_OK; if(strcmp(m_pszMediaFormat, kValueMediaFormatUncompVideo) == 0) { UINT32 nColorFormat = 0; UINT32 nVideoWidth = 0; UINT32 nVideoHeight = 0; pProps->GetUint(kPropVideoColorFormat, &nColorFormat); pProps->GetUint(kPropVideoFrameWidth, &nVideoWidth); pProps->GetUint(kPropVideoFrameHeight, &nVideoHeight); fprintf(stdout, "Preview %s:%d: OnFormatChanged(format=%d, videowidth=%d, videoheight=%d)\n", m_pszMediaFormat, m_nPreviewIndex, nColorFormat, nVideoWidth, nVideoHeight); #ifdef _WIN32 m_pWinPreview->FreeWindow(); if(m_nColorFormat == HXT_VIDEO_FORMAT_BGR24_INVERTED || m_nColorFormat == HXT_VIDEO_FORMAT_BGR24_NONINVERTED) { #ifdef _WIN32 m_pWinPreview->CreatePreviewWindow(m_nPreviewIndex, nVideoWidth, nVideoHeight); #endif } else { fprintf(stderr, "INFORMATIONAL: Unable to create the video preview window. The format must be RGB24 or RGB24 Inverted to display in the video window.\n"); } #endif } return res; } STDMETHODIMP CVideoPreviewSink::OnSample(IHXTMediaSample* pSample) { HX_RESULT res = HXR_FAIL; if(pSample) { pSample->AddRef(); HXT_TIME tmStart; HXT_TIME tmEnd; pSample->GetTime(&tmStart, &tmEnd); UINT32 ultstart = tmStart; UINT32 ultend = tmEnd; // printf("Preview %s:%d: OnSample start %lu, end %lu\n", // m_pszMediaFormat, m_nPreviewIndex, ultstart, ultend); #ifdef _WIN32 if(m_pWinPreview) { if(pSample->GetDataSize()) { m_pWinPreview->DrawVideo(pSample->GetDataStartForReading(), pSample->GetDataSize()); } } #endif pSample->Release(); res = HXR_OK; } return res; } --- NEW FILE: win.pcf --- # # ***** BEGIN LICENSE BLOCK ***** # Version: RCSL 1.0/RPSL 1.0 # # Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. # # The contents of this file, and the files included with this file, are # subject to the current version of the RealNetworks Public Source License # Version 1.0 (the "RPSL") available at # http://www.helixcommunity.org/content/rpsl unless you have licensed # the file under the RealNetworks Community Source License Version 1.0 # (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, # in which case the RCSL will apply. You may also obtain the license terms # directly from RealNetworks. You may not use this file except in # compliance with the RPSL or, if you have a valid RCSL with RealNetworks # applicable to this file, the RCSL. Please see the applicable RPSL or # RCSL for the rights, obligations and limitations governing use of the # contents of the file. # # This file is part of the Helix DNA Technology. RealNetworks is the # developer of the Original Code and owns the copyrights in the portions # it created. # # This file, and the files included with this file, is distributed and made # available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER # EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. # # Technology Compatibility Kit Test Suite(s) Location: # http://www.helixcommunity.org/content/tck # # Contributor(s): # # ***** END LICENSE BLOCK ***** # project.sys_libraries[-1:-1] = ['version.lib', 'wsock32.lib', 'kernel32.lib', 'user32.lib', 'vfw32.lib', 'advapi32.lib', 'gdi32.lib', 'comctl32.lib', 'ole32.lib', 'uuid.lib', 'winmm.lib'] project.AddSources('winpreview.cpp') --- NEW FILE: Umakefil --- # # ***** BEGIN LICENSE BLOCK ***** # Version: RCSL 1.0/RPSL 1.0 # # Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. # # The contents of this file, and the files included with this file, are # subject to the current version of the RealNetworks Public Source License # Version 1.0 (the "RPSL") available at # http://www.helixcommunity.org/content/rpsl unless you have licensed # the file under the RealNetworks Community Source License Version 1.0 # (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, # in which case the RCSL will apply. You may also obtain the license terms # directly from RealNetworks. You may not use this file except in # compliance with the RPSL or, if you have a valid RCSL with RealNetworks # applicable to this file, the RCSL. Please see the applicable RPSL or # RCSL for the rights, obligations and limitations governing use of the # contents of the file. # # This file is part of the Helix DNA Technology. RealNetworks is the # developer of the Original Code and owns the copyrights in the portions # it created. # # This file, and the files included with this file, is distributed and made # available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER # EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. # # Technology Compatibility Kit Test Suite(s) Location: # http://www.helixcommunity.org/content/tck # # Contributor(s): # # ***** END LICENSE BLOCK ***** # UmakefileVersion(2,1) project.AddModuleIncludes( 'common/include', 'common/runtime/pub', 'producersdk/include', 'producersdk/common/include', 'common/log/logobserverfile/pub') project.AddSources( 'samplepreviewsink.cpp', 'previewhelper.cpp') LibraryTarget('previewhelper') DependTarget() --- NEW FILE: samplepreviewsink.h --- /* ***** BEGIN LICENSE BLOCK ***** * Version: RCSL 1.0/RPSL 1.0 * * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, are * subject to the current version of the RealNetworks Public Source License * Version 1.0 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the RealNetworks Community Source License Version 1.0 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, * in which case the RCSL will apply. You may also obtain the license terms * directly from RealNetworks. You may not use this file except in * compliance with the RPSL or, if you have a valid RCSL with RealNetworks * applicable to this file, the RCSL. Please see the applicable RPSL or * RCSL for the rights, obligations and limitations governing use of the * contents of the file. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the portions * it created. * * This file, and the files included with this file, is distributed and made * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ #ifndef _SAMPLE_PREVIEW_SINK_H_ #define _SAMPLE_PREVIEW_SINK_H_ #include "hxcom.h" #include "ihxtpreviewsink.h" // Sample Preview sing class CSamplePreviewSink : public IHXTPreviewSink { public: CSamplePreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat); ~CSamplePreviewSink(); //IUnknown methods STDMETHOD_( ULONG32, AddRef )(); STDMETHOD_( ULONG32, Release )(); STDMETHOD( QueryInterface )( REFIID riid, void** ppvObj ); UINT32 GetPreviewSinkPosition() { return m_nPreviewPosition; }; INT32 GetOutputProfile() { return m_nOutputProfile; }; INT32 GetAudience() { return m_nAudience; }; protected: // IUnknown implemenation UINT32 m_ulRefCount; // preview sink implementation UINT32 m_nPreviewPosition; UINT32 m_nPreviewIndex; char* m_pszMediaFormat; INT32 m_nOutputProfile; INT32 m_nAudience; }; // Sample Preview sing class CAudioPreviewSink : public CSamplePreviewSink { public: CAudioPreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat, INT32 nSampleRate, INT32 nSampleFormat, INT32 nChannelFormat); ~CAudioPreviewSink(); STDMETHOD(OnFormatChanged)(THIS_ IHXTPropertyBag* pProps); STDMETHOD(OnSample)(THIS_ IHXTMediaSample* pSample); protected: UINT32 m_nSampleRate; UINT32 m_nSampleFormat; UINT32 m_nChannelFormat; }; // Sample Preview sing class CAudioLevelPreviewSink : public CAudioPreviewSink { public: CAudioLevelPreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat, INT32 nSampleRate = 0, INT32 nSampleFormat = 0, INT32 nChannelFormat = 0 ); ~CAudioLevelPreviewSink(); STDMETHOD(OnFormatChanged)(THIS_ IHXTPropertyBag* pProps); STDMETHOD(OnSample)(THIS_ IHXTMediaSample* pSample); }; #ifdef _WINDOWS class CWinPreview; #endif // Sample Preview sing class CVideoPreviewSink : public CSamplePreviewSink { public: CVideoPreviewSink( UINT32 nPreviewPosition, UINT nPreviewIndex, INT32 nOutputProfile, INT32 nAudience, const char* szMediaFormat, UINT32 nColorFormat = HXT_VIDEO_FORMAT_BGR24_INVERTED, UINT32 nVideoWidth = 160, UINT32 nVideoHeight = 120 ); ~CVideoPreviewSink(); // IHXTPreviewSink methods STDMETHOD(OnFormatChanged)(THIS_ IHXTPropertyBag* pProps); STDMETHOD(OnSample)(THIS_ IHXTMediaSample* pSample); private: UINT32 m_nColorFormat; #ifdef _WIN32 CWinPreview* m_pWinPreview; #endif }; #endif // _SAMPLE_PREVIEW_SINK_H_ --- NEW FILE: previewhelper.cpp --- /* ***** BEGIN LICENSE BLOCK ***** * Version: RCSL 1.0/RPSL 1.0 * * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, are * subject to the current version of the RealNetworks Public Source License * Version 1.0 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the RealNetworks Community Source License Version 1.0 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, * in which case the RCSL will apply. You may also obtain the license terms * directly from RealNetworks. You may not use this file except in * compliance with the RPSL or, if you have a valid RCSL with RealNetworks * applicable to this file, the RCSL. Please see the applicable RPSL or * RCSL for the rights, obligations and limitations governing use of the * contents of the file. * [...1293 lines suppressed...] } HX_RELEASE(pMediaProfile); } } HX_RELEASE(pOutputProfile); } } } } } } HX_RELEASE(pIHXTInputPreviewSinkControl); } m_bSinkEnabled = !m_bSinkEnabled; return res; }