Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
rtp_audio_file.h
Go to the documentation of this file.
1
9
10#ifndef RTP_AUDIO_FILE_H
11#define RTP_AUDIO_FILE_H
12
13#include "config.h"
14#include <ui/rtp_media.h>
15
16#include <QIODevice>
17#include <QDir>
18#include <QTemporaryFile>
19#include <QDebug>
20#include <QBuffer>
21
22struct _rtp_info;
23
31
35typedef struct {
36 qint64 real_pos;
37 qint64 sample_pos;
38 qint64 len;
39 uint32_t frame_num;
42
46class RtpAudioFile: public QIODevice
47{
48public:
54 explicit RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames);
55
60
61 // Functions for writing Frames
65 void setFrameWriteStage();
66
72 void frameWriteSilence(uint32_t frame_num, qint64 samples);
73
81 qint64 frameWriteSamples(uint32_t frame_num, const char *data, qint64 max_size);
82
83 // Functions for reading Frames
88 void setFrameReadStage(qint64 prepend_samples);
89
99 bool readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type);
100
101 // Functions for reading data during play
105 void setDataReadStage();
106
112 bool open(QIODevice::OpenMode mode) override;
113
118 qint64 size() const override;
119
124 qint64 pos() const override;
125
131 bool seek(qint64 off) override;
132
137 qint64 sampleFileSize();
138
143 void seekSample(qint64 samples);
144
150 qint64 readSample(SAMPLE *sample);
151
156 qint64 getTotalSamples();
157
162 qint64 getEndOfSilenceSample();
163
164protected:
165 // Functions for reading data during play
172 qint64 readData(char *data, qint64 maxSize) override;
173
180 qint64 writeData(const char *data, qint64 maxSize) override;
181
182private:
184 QIODevice *sample_file_;
185
187 QIODevice *sample_file_frame_;
188
190 qint64 real_pos_;
191
193 qint64 real_size_;
194
196 qint64 sample_pos_;
197
199 qint64 sample_size_;
200
202 rtp_frame_info cur_frame_;
203
204 // Functions for writing Frames
214 qint64 frameWriteFrame(uint32_t frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type);
215
220 void frameUpdateRealCounters(qint64 written_bytes);
221
226 void frameUpdateSampleCounters(qint64 written_bytes);
227
228 // Functions for reading Frames
229
230 // Functions for reading data during play
237 qint64 readFrameData(char *data , qint64 want_read);
238};
239
240#endif // RTP_AUDIO_FILE_H
RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames)
Constructs an RtpAudioFile object.
Definition rtp_audio_file.cpp:35
void frameWriteSilence(uint32_t frame_num, qint64 samples)
Writes a silence frame.
Definition rtp_audio_file.cpp:140
qint64 pos() const override
Gets the current byte position in the file.
Definition rtp_audio_file.cpp:236
bool seek(qint64 off) override
Seeks to a specific byte offset.
Definition rtp_audio_file.cpp:246
qint64 sampleFileSize()
Retrieves the underlying sample file size.
Definition rtp_audio_file.cpp:287
bool open(QIODevice::OpenMode mode) override
Opens the device with the specified mode.
Definition rtp_audio_file.cpp:222
qint64 writeData(const char *data, qint64 maxSize) override
Writes up to maxSize bytes of data from the given buffer.
Definition rtp_audio_file.cpp:379
qint64 getTotalSamples()
Gets the total number of samples.
Definition rtp_audio_file.cpp:325
~RtpAudioFile()
Destroys the RtpAudioFile object.
Definition rtp_audio_file.cpp:76
qint64 readSample(SAMPLE *sample)
Reads a single sample.
Definition rtp_audio_file.cpp:320
qint64 size() const override
Gets the size of the file.
Definition rtp_audio_file.cpp:231
void seekSample(qint64 samples)
Seeks to a specific sample position.
Definition rtp_audio_file.cpp:292
void setFrameWriteStage()
Sets the file to the frame write stage.
Definition rtp_audio_file.cpp:85
void setDataReadStage()
Sets the file to the data read stage for playback.
Definition rtp_audio_file.cpp:215
qint64 readData(char *data, qint64 maxSize) override
Reads up to maxSize bytes of data into the given buffer.
Definition rtp_audio_file.cpp:339
qint64 getEndOfSilenceSample()
Gets the sample index at the end of inserted silence.
Definition rtp_audio_file.cpp:330
bool readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type)
Reads samples for a single frame.
Definition rtp_audio_file.cpp:178
qint64 frameWriteSamples(uint32_t frame_num, const char *data, qint64 max_size)
Writes actual audio sample data for a frame.
Definition rtp_audio_file.cpp:150
void setFrameReadStage(qint64 prepend_samples)
Sets the file to the frame read stage.
Definition rtp_audio_file.cpp:169
rtp_frame_type
Defines the type of an RTP frame.
Definition rtp_audio_file.h:27
@ RTP_FRAME_SILENCE
Definition rtp_audio_file.h:29
@ RTP_FRAME_AUDIO
Definition rtp_audio_file.h:28
Definition packet-rtp.h:29
Structure used for storing frame num during visual waveform decoding.
Definition rtp_audio_file.h:35
qint64 real_pos
Definition rtp_audio_file.h:36
uint32_t frame_num
Definition rtp_audio_file.h:39
qint64 sample_pos
Definition rtp_audio_file.h:37
qint64 len
Definition rtp_audio_file.h:38
rtp_frame_type type
Definition rtp_audio_file.h:40