Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
rtp_audio_file.h
Go to the documentation of this file.
1
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 <speex/speex_resampler.h>
17
18#include <QIODevice>
19#include <QDir>
20#include <QTemporaryFile>
21#include <QDebug>
22#include <QBuffer>
23
24struct _rtp_info;
25
33
37typedef struct {
38 qint64 real_pos;
39 qint64 sample_pos;
40 qint64 len;
41 uint32_t frame_num;
44
48class RtpAudioFile: public QIODevice
49{
50public:
56 explicit RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames);
57
62
63 // Functions for writing Frames
67 void setFrameWriteStage();
68
74 void frameWriteSilence(uint32_t frame_num, qint64 samples);
75
83 qint64 frameWriteSamples(uint32_t frame_num, const char *data, qint64 max_size);
84
85 // Functions for reading Frames
90 void setFrameReadStage(qint64 prepend_samples);
91
101 bool readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type);
102
103 // Functions for reading data during play
107 void setDataReadStage();
108
114 bool open(QIODevice::OpenMode mode) override;
115
120 qint64 size() const override;
121
126 qint64 pos() const override;
127
133 bool seek(qint64 off) override;
134
139 qint64 sampleFileSize();
140
145 void seekSample(qint64 samples);
146
152 qint64 readSample(SAMPLE *sample);
153
158 qint64 getTotalSamples();
159
164 qint64 getEndOfSilenceSample();
165
166protected:
167 // Functions for reading data during play
174 qint64 readData(char *data, qint64 maxSize) override;
175
182 qint64 writeData(const char *data, qint64 maxSize) override;
183
184private:
186 QIODevice *sample_file_;
187
189 QIODevice *sample_file_frame_;
190
192 qint64 real_pos_;
193
195 qint64 real_size_;
196
198 qint64 sample_pos_;
199
201 qint64 sample_size_;
202
204 rtp_frame_info cur_frame_;
205
206 // Functions for writing Frames
216 qint64 frameWriteFrame(uint32_t frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type);
217
222 void frameUpdateRealCounters(qint64 written_bytes);
223
228 void frameUpdateSampleCounters(qint64 written_bytes);
229
230 // Functions for reading Frames
231
232 // Functions for reading data during play
239 qint64 readFrameData(char *data , qint64 want_read);
240};
241
242#endif // RTP_AUDIO_FILE_H
A QIODevice subclass that handles reading and writing of RTP audio files and frames.
Definition rtp_audio_file.h:49
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 readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type)
Reads samples for a single frame.
Definition rtp_audio_file.cpp:178
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
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:29
@ RTP_FRAME_SILENCE
Definition rtp_audio_file.h:31
@ RTP_FRAME_AUDIO
Definition rtp_audio_file.h:30
Definition packet-rtp.h:29
Structure used for storing frame num during visual waveform decoding.
Definition rtp_audio_file.h:37
qint64 real_pos
Definition rtp_audio_file.h:38
uint32_t frame_num
Definition rtp_audio_file.h:41
qint64 sample_pos
Definition rtp_audio_file.h:39
qint64 len
Definition rtp_audio_file.h:40
rtp_frame_type type
Definition rtp_audio_file.h:42