~ubuntu-branches/ubuntu/precise/mpeg4ip/precise

« back to all changes in this revision

Viewing changes to player/src/mpeg2t_bytestream.h

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2008-01-12 15:59:56 UTC
  • Revision ID: james.westby@ubuntu.com-20080112155956-1vznw5njidvrh649
Tags: upstream-1.6dfsg
ImportĀ upstreamĀ versionĀ 1.6dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The contents of this file are subject to the Mozilla Public
 
3
 * License Version 1.1 (the "License"); you may not use this file
 
4
 * except in compliance with the License. You may obtain a copy of
 
5
 * the License at http://www.mozilla.org/MPL/
 
6
 * 
 
7
 * Software distributed under the License is distributed on an "AS
 
8
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 * implied. See the License for the specific language governing
 
10
 * rights and limitations under the License.
 
11
 * 
 
12
 * The Original Code is MPEG4IP.
 
13
 * 
 
14
 * The Initial Developer of the Original Code is Cisco Systems Inc.
 
15
 * Portions created by Cisco Systems Inc. are
 
16
 * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
 
17
 * 
 
18
 * Contributor(s): 
 
19
 *              Bill May        wmay@cisco.com
 
20
 */
 
21
/*
 
22
 * mp4_bytestream.h - provides bytestream access to quicktime files
 
23
 */
 
24
 
 
25
#ifndef __MPEG2T_BYTESTREAM_H__
 
26
#define __MPEG2T_BYTESTREAM_H__
 
27
#include "our_bytestream.h"
 
28
#include "player_util.h"
 
29
#include "mpeg2t_private.h"
 
30
#include "mpeg2t/mpeg2_transport.h"
 
31
//#define OUTPUT_TO_FILE 1
 
32
 
 
33
/*
 
34
 * CMpeg2tByteStreamBase provides base class access to quicktime files.
 
35
 * Most functions are shared between audio and video.
 
36
 */
 
37
class CMpeg2tByteStream : public COurInByteStream
 
38
{
 
39
 public:
 
40
  CMpeg2tByteStream(mpeg2t_es_t *es_pid,
 
41
                    const char *type,
 
42
                    int has_video, 
 
43
                    int ondemand);
 
44
  ~CMpeg2tByteStream();
 
45
  int eof(void);
 
46
  virtual void reset(void);
 
47
  int have_no_data(void);
 
48
  bool start_next_frame(uint8_t **buffer,
 
49
                        uint32_t *buflen,
 
50
                        frame_timestamp_t *ts,
 
51
                        void **ud);
 
52
  void used_bytes_for_frame(uint32_t bytes);
 
53
  int can_skip_frame(void) { return 1; };
 
54
  bool skip_next_frame(frame_timestamp_t *ts, int *hasSyncFrame, 
 
55
                      uint8_t **buffer,
 
56
                      uint32_t *buflen, void **ud);
 
57
  void check_for_end_of_frame(void);
 
58
  double get_max_playtime(void);
 
59
 
 
60
  void play(uint64_t start);
 
61
  void pause(void);
 
62
 protected:
 
63
#ifdef OUTPUT_TO_FILE
 
64
  FILE *m_output_file;
 
65
#endif
 
66
  int m_has_video;
 
67
  mpeg2t_es_t *m_es_pid;
 
68
  virtual int get_timestamp_for_frame(mpeg2t_frame_t *, 
 
69
                                      frame_timestamp_t *ts) = 0;
 
70
  mpeg2t_frame_t *m_frame;
 
71
  int m_timestamp_loaded;
 
72
  uint64_t m_last_timestamp;
 
73
  uint32_t m_audio_last_freq_timestamp;
 
74
  int m_frames_since_last_timestamp;
 
75
  int m_ondemand;
 
76
  mpeg2t_stream_t *m_stream_ptr;
 
77
};
 
78
 
 
79
/*
 
80
 * CMp4VideoByteStream is for video streams.  It is inherited from
 
81
 * CMpeg2tByteStreamBase.
 
82
 */
 
83
class CMpeg2tVideoByteStream : public CMpeg2tByteStream
 
84
{
 
85
 public:
 
86
  CMpeg2tVideoByteStream(mpeg2t_es_t *es_pid, int ondemand) :
 
87
    CMpeg2tByteStream(es_pid, "video", 1, ondemand) {
 
88
    m_have_prev_frame_type = 0;
 
89
  };
 
90
  void reset(void);
 
91
 protected:
 
92
  int get_timestamp_for_frame(mpeg2t_frame_t *, frame_timestamp_t *ts);
 
93
  int m_have_prev_frame_type;
 
94
  int m_prev_frame_type;
 
95
  uint64_t m_prev_ts;
 
96
};
 
97
 
 
98
/*
 
99
 * CMp4AudioByteStream is for audio streams.  It is inherited from
 
100
 * CMpeg2tByteStreamBase.
 
101
 */
 
102
class CMpeg2tAudioByteStream : public CMpeg2tByteStream
 
103
{
 
104
 public:
 
105
  CMpeg2tAudioByteStream(mpeg2t_es_t *es_pid, int ondemand) :
 
106
    CMpeg2tByteStream(es_pid, "audio", 0, ondemand) {};
 
107
  void reset(void);
 
108
 protected:
 
109
  int get_timestamp_for_frame(mpeg2t_frame_t *, frame_timestamp_t *ts);
 
110
 
 
111
};
 
112
 
 
113
#endif
 
114
 
 
115
 
 
116