summaryrefslogtreecommitdiffstats
path: root/media/tools/player_wtl/movie.h
blob: ea81b09ad284c362ab57bf8e6d660acc5794b865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Movie class for WTL forms to call to control the media pipeline.

#ifndef MEDIA_TOOLS_PLAYER_WTL_MOVIE_H_
#define MEDIA_TOOLS_PLAYER_WTL_MOVIE_H_

#include "media/tools/player_wtl/player_wtl.h"

#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/threading/thread.h"

template <typename T> struct DefaultSingletonTraits;
class WtlVideoRenderer;

namespace media {

class PipelineImpl;

class Movie {
 public:
   // Returns the singleton instance.
  static Movie* GetInstance();

  // Open a movie.
  bool Open(const wchar_t* url, WtlVideoRenderer* video_renderer);

  // Set playback rate.
  void Play(float rate);

  // Set playback rate.
  float GetPlayRate();

  // Get movie duration in seconds.
  float GetDuration();

  // Get current movie position in seconds.
  float GetPosition();

  // Set current movie position in seconds.
  void SetPosition(float position);

  // Set playback pause.
  void SetPause(bool pause);

  // Get playback pause state.
  bool GetPause();

  // Set buffer to render into.
  void SetFrameBuffer(HBITMAP hbmp, HWND hwnd);

  // Close movie.
  void Close();

  // Query if movie is currently open.
  bool IsOpen();

  // Enable/Disable audio.
  void SetAudioEnable(bool enable_audio);

  // Get Enable/Disable audio state.
  bool GetAudioEnable();

  // Enable/Disable draw.
  void SetDrawEnable(bool enable_draw);

  // Get Enable/Disable draw state.
  bool GetDrawEnable();

  // Enable/Disable dump yuv file.
  void SetDumpYuvFileEnable(bool enable_dump_yuv_file);

  // Get Enable/Disable dump yuv file state.
  bool GetDumpYuvFileEnable();

 private:
  // Only allow Singleton to create and delete Movie.
  friend struct DefaultSingletonTraits<Movie>;
  Movie();
  virtual ~Movie();

  scoped_refptr<PipelineImpl> pipeline_;
  scoped_ptr<base::Thread> thread_;

  bool enable_audio_;
  bool enable_draw_;
  bool enable_dump_yuv_file_;
  bool enable_pause_;
  int max_threads_;
  float play_rate_;
  HBITMAP movie_dib_;
  HWND movie_hwnd_;

  DISALLOW_COPY_AND_ASSIGN(Movie);
};

}  // namespace media

#endif  // MEDIA_TOOLS_PLAYER_WTL_MOVIE_H_