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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/*
* Copyright (C) 2000-2001 the xine project
*
* This file is part of xine, a unix video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: metronom.h,v 1.1 2001/04/18 22:36:07 f1rmb Exp $
*
* metronom: general pts => virtual calculation/assoc
*
* virtual pts: unit 1/90000 sec, always increasing
* can be used for synchronization
* video/audio frame with same pts also have same vpts
* but pts is likely to differ from vpts
*
*/
#ifndef HAVE_METRONOM_H
#define HAVE_METRONOM_H
#include <inttypes.h>
#include <sys/time.h>
typedef struct metronom_s metronom_t ;
struct metronom_s {
/*
* clear all cached data, reset current vpts ... called if new input
* file is reached
*/
void (*reset) (metronom_t *this);
/*
* called by video output driver to inform metronom about current framerate
*
* parameter pts_per_frame : frame display duration in 1/90000 sec
*/
void (*set_video_rate) (metronom_t *this, uint32_t pts_per_frame);
/*
* return current video rate (including delta corrections)
*/
uint32_t (*get_video_rate) (metronom_t *this);
/*
* called by audio output driver to inform metronom about current audio
* bitrate
*
* parameter pts_per_smpls : 1/90000 sec per 65536 samples
*/
void (*set_audio_rate) (metronom_t *this, uint32_t pts_per_smpls);
/*
* called by video output driver for *every* frame
*
* parameter pts: pts for frame if known, 0 otherwise
*
* return value: virtual pts for frame
*
*/
uint32_t (*got_video_frame) (metronom_t *this, uint32_t pts);
/*
* called by audio output driver whenever audio samples are delivered to it
*
* parameter pts : pts for audio data if known, 0 otherwise
* nsamples : number of samples delivered
*
* return value: virtual pts for audio data
*
*/
uint32_t (*got_audio_samples) (metronom_t *this, uint32_t pts, uint32_t nsamples);
/*
* called by SPU decoder whenever a packet is delivered to it
*
* parameter pts : pts for SPU packet if known, 0 otherwise
*
* return value: virtual pts for SPU packet
*
*/
uint32_t (*got_spu_packet) (metronom_t *this, uint32_t pts);
/*
* manually correct audio <-> video sync
*/
void (*set_av_offset) (metronom_t *this, int32_t pts);
int32_t (*get_av_offset) (metronom_t *this);
/*
* ****************************************
* master clock functions
* ****************************************
*/
/*
* start metronom clock (no clock reset)
*/
void (*start_clock) (metronom_t *this, uint32_t pts);
/*
* stop metronom clock
*/
void (*stop_clock) (metronom_t *this);
/*
* resume clock from where it was stopped
*/
void (*resume_clock) (metronom_t *this);
/*
* get current clock value in vpts
*/
uint32_t (*get_current_time) (metronom_t *this);
/*
* adjust master clock to external timer (e.g. audio hardware)
*/
void (*adjust_clock) (metronom_t *this, uint32_t desired_pts);
/*
* metronom internal stuff
*/
uint32_t pts_per_frame;
uint32_t pts_per_smpls;
int32_t audio_pts_delta;
uint32_t video_vpts;
uint32_t audio_vpts;
uint32_t sync_pts;
uint32_t sync_vpts;
/* video delta for wrong framerates */
uint32_t last_video_pts;
uint32_t last_video_vpts;
int num_video_vpts_guessed;
int32_t video_pts_delta;
int num_audio_samples_guessed;
int32_t av_offset;
struct timeval start_time;
uint32_t start_pts, last_pts;
int stopped ;
};
metronom_t *metronom_init ();
#endif
|