~ubuntu-branches/ubuntu/quantal/gst-plugins-bad-multiverse0.10/quantal

« back to all changes in this revision

Viewing changes to gst-libs/gst/dshow/gstdshowfakesink.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2009-12-07 08:54:28 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20091207085428-ml6aaukf0p2ph34d
Tags: 0.10.17-0ubuntu1
* New upstream release.
* Add myself to maintainer.
* Fix misc lintian warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* GStreamer
2
 
 * Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
3
 
 *
4
 
 * gstdshowfakesink.cpp:
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU Library General Public
8
 
 * License as published by the Free Software Foundation; either
9
 
 * version 2 of the License, or (at your option) any later version.
10
 
 *
11
 
 * This library is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 
 * Library General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU Library General Public
17
 
 * License along with this library; if not, write to the
18
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 
 * Boston, MA 02111-1307, USA.
20
 
 */
21
 
 
22
 
#include "gstdshowfakesink.h"
23
 
 
24
 
 
25
 
CDshowFakeSink::CDshowFakeSink()
26
 
  : m_hres(S_OK), CBaseRenderer(CLSID_DshowFakeSink, "DshowFakeSink", NULL, &m_hres)
27
 
{
28
 
  m_callback = NULL;
29
 
}
30
 
 
31
 
CDshowFakeSink::~CDshowFakeSink()
32
 
{
33
 
 
34
 
}
35
 
 
36
 
//Object creation.
37
 
CUnknown* WINAPI CDshowFakeSink::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
38
 
{
39
 
        CDshowFakeSink *pNewObject = new CDshowFakeSink();
40
 
  if (pNewObject == NULL) {
41
 
    *pHr = E_OUTOFMEMORY;
42
 
  }
43
 
  return pNewObject;
44
 
45
 
 
46
 
STDMETHODIMP CDshowFakeSink::QueryInterface(REFIID riid, void **ppvObject)
47
 
{
48
 
  if (riid == IID_IGstDshowInterface) {
49
 
      *ppvObject = (IGstDshowInterface*) this;
50
 
      AddRef();
51
 
      return S_OK;
52
 
  }
53
 
  else
54
 
    return CBaseRenderer::QueryInterface (riid, ppvObject);
55
 
}
56
 
 
57
 
ULONG STDMETHODCALLTYPE CDshowFakeSink::AddRef()
58
 
{
59
 
  return CBaseRenderer::AddRef();
60
 
}
61
 
 
62
 
ULONG STDMETHODCALLTYPE CDshowFakeSink::Release()
63
 
{
64
 
  return CBaseRenderer::Release();
65
 
}
66
 
 
67
 
 
68
 
STDMETHODIMP CDshowFakeSink::gst_set_media_type (AM_MEDIA_TYPE *pmt)
69
 
{
70
 
  m_MediaType.Set (*pmt);
71
 
  return S_OK;
72
 
}
73
 
 
74
 
STDMETHODIMP CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push, byte *data)
75
 
{
76
 
  m_callback = push;
77
 
  m_data = data;
78
 
  return S_OK;
79
 
}
80
 
 
81
 
STDMETHODIMP CDshowFakeSink::gst_push_buffer (byte *buffer, __int64 start, __int64 stop, unsigned int size, bool discount)
82
 
{
83
 
  return E_NOTIMPL;
84
 
}
85
 
 
86
 
STDMETHODIMP CDshowFakeSink::gst_flush ()
87
 
{
88
 
  return E_NOTIMPL;
89
 
}
90
 
 
91
 
STDMETHODIMP CDshowFakeSink::gst_set_sample_size(unsigned int size)
92
 
{
93
 
  return E_NOTIMPL;
94
 
}
95
 
 
96
 
HRESULT CDshowFakeSink::CheckMediaType(const CMediaType *pmt)
97
 
{
98
 
  VIDEOINFOHEADER *p1;
99
 
  VIDEOINFOHEADER *p2;
100
 
  if(pmt != NULL)
101
 
  {
102
 
    p1 = (VIDEOINFOHEADER *)pmt->Format();
103
 
    p2 = (VIDEOINFOHEADER *)m_MediaType.Format();
104
 
    if (*pmt == m_MediaType)
105
 
      return S_OK;
106
 
  }
107
 
 
108
 
  return S_FALSE;
109
 
}
110
 
 
111
 
HRESULT CDshowFakeSink::DoRenderSample(IMediaSample *pMediaSample)
112
 
{
113
 
  if(pMediaSample && m_callback)
114
 
  {
115
 
    BYTE *pBuffer = NULL;
116
 
    LONGLONG lStart = 0, lStop = 0;
117
 
    pMediaSample->GetPointer(&pBuffer);
118
 
    long size = pMediaSample->GetActualDataLength();
119
 
    pMediaSample->GetTime(&lStart, &lStop);
120
 
    lStart*=100;
121
 
    lStop*=100;
122
 
    m_callback(pBuffer, size, m_data, lStart, lStop);
123
 
  }
124
 
  
125
 
  return S_OK;
126
 
}