summaryrefslogtreecommitdiffstats
path: root/media/base/filter_host.h
blob: 4bdad9f330560e213dec85d2cb3f8e38309e0982 (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
// Copyright (c) 2011 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.

// FilterHost describes an interface for individual filters to access and
// modify global playback information.  Every filter is given a filter host
// reference as part of initialization.
//
// This interface is intentionally verbose to cover the needs for the different
// types of filters (see media/base/filters.h for filter definitions).  Filters
// typically use parts of the interface that are relevant to their function.
// For example, an audio renderer filter typically calls SetTime as it feeds
// data to the audio hardware.  A video renderer filter typically calls GetTime
// to synchronize video with audio.  An audio and video decoder would typically
// have no need to call either SetTime or GetTime.

#ifndef MEDIA_BASE_FILTER_HOST_H_
#define MEDIA_BASE_FILTER_HOST_H_

#include "media/base/filters.h"
#include "media/base/pipeline.h"

namespace media {

class FilterHost {
 public:
  // Stops execution of the pipeline due to a fatal error.  Do not call this
  // method with PIPELINE_OK.
  virtual void SetError(PipelineStatus error) = 0;

  // Gets the current time in microseconds.
  virtual base::TimeDelta GetTime() const = 0;

  // Gets the duration in microseconds.
  virtual base::TimeDelta GetDuration() const = 0;

  // Updates the current time.  Other filters should poll to examine the updated
  // time.
  virtual void SetTime(base::TimeDelta time) = 0;

  // Get the duration of the media in microseconds.  If the duration has not
  // been determined yet, then returns 0.
  virtual void SetDuration(base::TimeDelta duration) = 0;

  // Set the approximate amount of playable data buffered so far in micro-
  // seconds.
  virtual void SetBufferedTime(base::TimeDelta buffered_time) = 0;

  // Set the total size of the media file.
  virtual void SetTotalBytes(int64 total_bytes) = 0;

  // Sets the total number of bytes that are buffered on the client and ready to
  // be played.
  virtual void SetBufferedBytes(int64 buffered_bytes) = 0;

  // Sets the size of the video output in pixel units.
  virtual void SetVideoSize(size_t width, size_t height) = 0;

  // Sets the flag to indicate that we are doing streaming.
  virtual void SetStreaming(bool streaming) = 0;

  // Notifies that this filter has ended, typically only called by filter graph
  // endpoints such as renderers.
  virtual void NotifyEnded() = 0;

  // Sets the flag to indicate that our media is now loaded.
  virtual void SetLoaded(bool loaded) = 0;

  // Sets the flag to indicate current network activity.
  virtual void SetNetworkActivity(bool network_activity) = 0;

  // Disable audio renderer by calling OnAudioRendererDisabled() on all
  // filters.
  virtual void DisableAudioRenderer() = 0;

  // Sets the byte offset at which the client is requesting the video.
  virtual void SetCurrentReadPosition(int64 offset) = 0;

  // Gets the byte offset at which the client is requesting the video.
  virtual int64 GetCurrentReadPosition() = 0;

 protected:
  virtual ~FilterHost() {}
};

}  // namespace media

#endif  // MEDIA_BASE_FILTER_HOST_H_