MythTV  0.28pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Modules Pages
videoout_null.cpp
Go to the documentation of this file.
1 #include <map>
2 #include <iostream>
3 using namespace std;
4 
5 #include "mythlogging.h"
6 #include "videoout_null.h"
7 #include "videodisplayprofile.h"
8 
9 const int kNumBuffers = 31;
10 const int kNeedFreeFrames = 1;
11 const int kPrebufferFramesNormal = 12;
12 const int kPrebufferFramesSmall = 4;
13 const int kKeepPrebuffer = 2;
14 
16  QStringList &cpudeints)
17 {
18  opts.renderers->append("null");
19  opts.deints->insert("null", cpudeints);
20  (*opts.osds)["null"].append("softblend");
21  (*opts.safe_renderers)["dummy"].append("null");
22  (*opts.safe_renderers)["nuppel"].append("null");
23  if (opts.decoders->contains("ffmpeg"))
24  (*opts.safe_renderers)["ffmpeg"].append("null");
25  if (opts.decoders->contains("crystalhd"))
26  (*opts.safe_renderers)["crystalhd"].append("null");
27  if (opts.decoders->contains("vda"))
28  (*opts.safe_renderers)["vda"].append("null");
29 
30  opts.priorities->insert("null", 10);
31 }
32 
34  VideoOutput(), global_lock(QMutex::Recursive)
35 {
36  LOG(VB_PLAYBACK, LOG_INFO, "VideoOutputNull()");
37  memset(&av_pause_frame, 0, sizeof(av_pause_frame));
38 }
39 
41 {
42  LOG(VB_PLAYBACK, LOG_INFO, "~VideoOutputNull()");
43  QMutexLocker locker(&global_lock);
44 
45  if (av_pause_frame.buf)
46  {
47  delete [] av_pause_frame.buf;
48  memset(&av_pause_frame, 0, sizeof(av_pause_frame));
49  }
50 
52 }
53 
54 // this is documented in videooutbase.cpp
56 {
57  QMutexLocker locker(&global_lock);
58  VideoOutput::Zoom(direction);
59  MoveResize();
60 }
61 
63 {
64  if (av_pause_frame.buf)
65  {
66  delete [] av_pause_frame.buf;
67  av_pause_frame.buf = NULL;
68  }
69 
71  new unsigned char[vbuffers.GetScratchFrame()->size + 128],
75 
77 
79 }
80 
81 bool VideoOutputNull::InputChanged(const QSize &video_dim_buf,
82  const QSize &video_dim_disp,
83  float aspect,
84  MythCodecID av_codec_id,
85  void *codec_private,
86  bool &aspect_only)
87 {
88  LOG(VB_PLAYBACK, LOG_INFO,
89  QString("InputChanged(WxH = %1x%2, aspect = %3)")
90  .arg(video_dim_disp.width())
91  .arg(video_dim_disp.height()).arg(aspect));
92 
93  if (!codec_is_std(av_codec_id))
94  {
95  LOG(VB_GENERAL, LOG_ERR, QString("VideoOutputNull::InputChanged(): "
96  "new video codec is not supported."));
98  return false;
99  }
100 
101  QMutexLocker locker(&global_lock);
102 
103  if (video_dim_disp == window.GetActualVideoDim())
104  {
105  vbuffers.Clear();
106  MoveResize();
107  return true;
108  }
109 
110  VideoOutput::InputChanged(video_dim_buf, video_dim_disp,
111  aspect, av_codec_id, codec_private,
112  aspect_only);
114 
115  MoveResize();
116 
117  const QSize video_dim = window.GetVideoDim();
118 
119  bool ok = vbuffers.CreateBuffers(FMT_YV12, video_dim.width(),
120  video_dim.height());
121  if (!ok)
122  {
123  LOG(VB_GENERAL, LOG_ERR, "VideoOutputNull::InputChanged(): "
124  "Failed to recreate buffers");
126  }
127  else
128  {
130  }
131 
132  if (db_vdisp_profile)
134 
135  return ok;
136 }
137 
138 bool VideoOutputNull::Init(const QSize &video_dim_buf,
139  const QSize &video_dim_disp,
140  float aspect, WId winid,
141  const QRect &win_rect, MythCodecID codec_id)
142 {
143  if ((video_dim_disp.width() <= 0) || (video_dim_disp.height() <= 0))
144  return false;
145 
146  if (!codec_is_std(codec_id))
147  {
148  LOG(VB_GENERAL, LOG_ERR,
149  QString("Cannot create VideoOutputNull for codec %1")
150  .arg(toString(codec_id)));
151  return false;
152  }
153 
154  QMutexLocker locker(&global_lock);
155 
156  VideoOutput::Init(video_dim_buf, video_dim_disp,
157  aspect, winid, win_rect, codec_id);
158 
162 
163  // XXX should this be GetActualVideoDim() ?
164  const QSize video_dim = window.GetVideoDim();
165 
166  if (!vbuffers.CreateBuffers(FMT_YV12, video_dim.width(), video_dim.height()))
167  return false;
168 
170 
171  if (db_vdisp_profile)
173 
174  MoveResize();
175 
176  return true;
177 }
178 
179 void VideoOutputNull::EmbedInWidget(const QRect &rect)
180 {
181  QMutexLocker locker(&global_lock);
182  if (!window.IsEmbedding())
184 }
185 
187 {
188  QMutexLocker locker(&global_lock);
189  if (window.IsEmbedding())
191 }
192 
194  OSD *osd)
195 {
196  (void)osd;
197  (void)t;
198 
199  if (!buffer)
200  buffer = vbuffers.GetScratchFrame();
201 
202  framesPlayed = buffer->frameNumber + 1;
203 }
204 
206 {
207 }
208 
210 {
211 }
212 
213 void VideoOutputNull::UpdatePauseFrame(int64_t &disp_timecode)
214 {
215  QMutexLocker locker(&global_lock);
216 
217  // Try used frame first, then fall back to scratch frame.
219  VideoFrame *used_frame = NULL;
221  used_frame = vbuffers.Head(kVideoBuffer_used);
222 
223  if (used_frame)
224  CopyFrame(&av_pause_frame, used_frame);
225  vbuffers.end_lock();
226 
227  if (!used_frame)
228  {
231  }
232 
233  disp_timecode = av_pause_frame.disp_timecode;
234 }
235 
237  FilterChain *filterList,
238  const PIPMap &pipPlayers,
240 {
241  (void)frame;
242  (void)osd;
243  (void)filterList;
244  (void)pipPlayers;
245  (void)scan;
246 }
GLuint buffer
void ProcessFrame(VideoFrame *frame, OSD *osd, FilterChain *filterList, const PIPMap &pipPlayers, FrameScanType scan)
void SetVideoRenderer(const QString &video_renderer)
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: videooutbase.h:37
priority_map_t * priorities
void CreatePauseFrame(void)
bool Init(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id)
Performs most of the initialization for VideoOutput.
QString toString(MarkTypes type)
MythCodecID
Definition: mythcodecid.h:10
safe_list_t * renderers
const int kPrebufferFramesNormal
safe_map_t * deints
virtual bool Init(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id)
Performs most of the initialization for VideoOutput.
QSize GetActualVideoDim(void) const
FrameScanType
Definition: videoouttypes.h:76
virtual void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
void Zoom(ZoomDirection direction)
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize()...
virtual bool InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID myth_codec_id, void *codec_private, bool &aspect_changed)
Tells video output to discard decoded frames and wait for new ones.
void PrepareFrame(VideoFrame *buffer, FrameScanType, OSD *osd)
VideoDisplayProfile * db_vdisp_profile
Definition: videooutbase.h:314
bool InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID av_codec_id, void *codec_private, bool &aspect_only)
Tells video output to discard decoded frames and wait for new ones.
virtual void EmbedInWidget(const QRect &rect)
Tells video output to embed video in an existing window.
long long framesPlayed
Definition: videooutbase.h:345
bool CreateBuffers(VideoFrameType type, int width, int height, vector< unsigned char * > bufs, vector< YUVInfo > yuvinfo)
safe_list_t * decoders
void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
This class serves as the base class for all video output methods.
Definition: videooutbase.h:46
safe_map_t * osds
static void CopyFrame(VideoFrame *to, const VideoFrame *from)
Copies frame data from one VideoFrame to another.
void UpdatePauseFrame(int64_t &disp_timecode)
Updates frame displayed when video is paused.
VideoBuffers vbuffers
VideoBuffers instance used to track video output buffers.
Definition: videooutbase.h:341
QSize GetVideoDim(void) const
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:816
void Show(FrameScanType)
int height
Definition: mythframe.h:37
const int kNumBuffers
VideoErrorState errorState
Definition: videooutbase.h:344
unsigned char t
Definition: ParseText.cpp:339
const int kNeedFreeFrames
long long frameNumber
Definition: mythframe.h:43
void end_lock()
Definition: videobuffers.h:99
VideoFrame av_pause_frame
Definition: videoout_null.h:47
const int kKeepPrebuffer
static void GetRenderOptions(render_opts &opts, QStringList &cpudeints)
VideoFrame * GetScratchFrame(void)
int64_t disp_timecode
Definition: mythframe.h:45
uint Size(BufferType type) const
void EmbedInWidget(const QRect &rect)
Tells video output to embed video in an existing window.
typedef void(APIENTRY *MYTH_GLTEXIMAGE1DPROC)(GLenum target
safe_map_t * safe_renderers
VideoFrame * Head(BufferType)
virtual void Zoom(ZoomDirection direction)
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize()...
virtual void MoveResize(void)
performs all the calculations for video framing and any resizing.
void Clear(uint i)
Definition: osd.h:131
const int kPrebufferFramesSmall
VideoOutWindow window
Definition: videooutbase.h:304
static void init(VideoFrame *vf, VideoFrameType _codec, unsigned char *_buf, int _width, int _height, int _size, const int *p=0, const int *o=0, float _aspect=-1.0f, double _rate=-1.0f, int _aligned=64) MUNUSED
Definition: mythframe.h:104
void Init(uint numdecode, bool extra_for_pause, uint need_free, uint needprebuffer_normal, uint needprebuffer_small, uint keepprebuffer)
Creates buffers and sets various buffer management parameters.
frame_queue_t::iterator begin_lock(BufferType)
void DrawUnusedRects(bool sync=true)
Draws non-video portions of the screen.
unsigned char * buf
Definition: mythframe.h:34
ZoomDirection
Definition: videoouttypes.h:28
void DeleteBuffers(void)
bool IsEmbedding(void) const
Returns if videooutput is embedding.