Wireshark  4.3.0
The Wireshark network protocol analyzer
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 
24 struct _rtp_info;
25 
26 typedef enum {
27  RTP_FRAME_AUDIO = 0,
28  RTP_FRAME_SILENCE
29 } rtp_frame_type;
30 
31 // Structure used for storing frame num during visual waveform decoding
32 typedef struct {
33  qint64 real_pos;
34  qint64 sample_pos;
35  qint64 len;
36  uint32_t frame_num;
37  rtp_frame_type type;
39 
40 
41 class RtpAudioFile: public QIODevice
42 {
43 public:
44  explicit RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames);
45  ~RtpAudioFile();
46 
47  // Functions for writing Frames
48  void setFrameWriteStage();
49  void frameWriteSilence(uint32_t frame_num, qint64 samples);
50  qint64 frameWriteSamples(uint32_t frame_num, const char *data, qint64 max_size);
51 
52  // Functions for reading Frames
53  void setFrameReadStage(qint64 prepend_samples);
54  bool readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type);
55 
56  // Functions for reading data during play
57  void setDataReadStage();
58  bool open(QIODevice::OpenMode mode) override;
59  qint64 size() const override;
60  qint64 pos() const override;
61  bool seek(qint64 off) override;
62  qint64 sampleFileSize();
63  void seekSample(qint64 samples);
64  qint64 readSample(SAMPLE *sample);
65  qint64 getTotalSamples();
66  qint64 getEndOfSilenceSample();
67 
68 protected:
69  // Functions for reading data during play
70  qint64 readData(char *data, qint64 maxSize) override;
71  qint64 writeData(const char *data, qint64 maxSize) override;
72 
73 private:
74  QIODevice *sample_file_; // Stores waveform samples
75  QIODevice *sample_file_frame_; // Stores rtp_packet_info per packet
76  qint64 real_pos_;
77  qint64 real_size_;
78  qint64 sample_pos_;
79  qint64 sample_size_;
80  rtp_frame_info cur_frame_;
81 
82  // Functions for writing Frames
83  qint64 frameWriteFrame(uint32_t frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type);
84  void frameUpdateRealCounters(qint64 written_bytes);
85  void frameUpdateSampleCounters(qint64 written_bytes);
86 
87  // Functions for reading Frames
88 
89  // Functions for reading data during play
90  qint64 readFrameData(char *data , qint64 want_read);
91 };
92 
93 #endif // RTP_AUDIO_FILE_H
Definition: rtp_audio_file.h:42
Definition: packet-rtp.h:29
Definition: rtp_audio_file.h:32