Skip to content

Commit 74da3f8

Browse files
committed
CodecParameters: added some getters & setters
Not complete, just most often used by code for now. Other still accessible via CodecParametersView::raw()->XXX
1 parent 64d57e4 commit 74da3f8

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

src/codecparameters.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,60 @@ int CodecParametersView::getAudioFrameDuration(int frame_bytes) const
100100
return av_get_audio_frame_duration2(const_cast<AVCodecParameters*>(m_raw), frame_bytes);
101101
}
102102

103+
AVMediaType CodecParametersView::codecType() const
104+
{
105+
return m_raw ? m_raw->codec_type : AVMEDIA_TYPE_UNKNOWN;
106+
}
107+
108+
void CodecParametersView::codecType(AVMediaType codec_type)
109+
{
110+
if (m_raw)
111+
m_raw->codec_type = codec_type;
112+
}
113+
114+
115+
AVMediaType CodecParametersView::mediaType() const
116+
{
117+
return codecType();
118+
}
119+
120+
void CodecParametersView::mediaType(AVMediaType media_type)
121+
{
122+
codecType(media_type);
123+
}
124+
125+
126+
AVCodecID CodecParametersView::codecId() const
127+
{
128+
return m_raw ? m_raw->codec_id : AV_CODEC_ID_NONE;
129+
}
130+
131+
void CodecParametersView::codecId(AVCodecID codec_id)
132+
{
133+
if (m_raw)
134+
m_raw->codec_id = codec_id;
135+
}
136+
137+
Codec CodecParametersView::encodingCodec() const
138+
{
139+
return m_raw ? findEncodingCodec(m_raw->codec_id) : Codec();
140+
}
141+
142+
Codec CodecParametersView::decodingCodec() const
143+
{
144+
return m_raw ? findDecodingCodec(m_raw->codec_id) : Codec();
145+
}
146+
147+
uint32_t CodecParametersView::codecTag() const
148+
{
149+
return m_raw ? m_raw->codec_tag : 0u;
150+
}
151+
152+
void CodecParametersView::codecTag(uint32_t codec_tag)
153+
{
154+
if (m_raw)
155+
m_raw->codec_tag = codec_tag;
156+
}
103157

104158

105159
CodecParameters::CodecParameters()

src/codecparameters.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "averror.h"
44
#include "ffmpeg.h"
55
#include "avutils.h"
6+
#include "codec.h"
67

78
extern "C" {
89
#include <libavcodec/codec_par.h>
@@ -29,6 +30,25 @@ class CodecParametersView : public FFWrapperPtr<AVCodecParameters>
2930
void copyTo(class CodecContext2& dst, OptionalErrorCode ec = throws()) const;
3031

3132
int getAudioFrameDuration(int frame_bytes) const;
33+
34+
// Getters & Setters
35+
36+
AVMediaType codecType() const;
37+
void codecType(AVMediaType codec_type);
38+
39+
AVMediaType mediaType() const;
40+
void mediaType(AVMediaType media_type);
41+
42+
AVCodecID codecId() const;
43+
void codecId(AVCodecID codec_id);
44+
45+
Codec encodingCodec() const;
46+
Codec decodingCodec() const;
47+
48+
uint32_t codecTag() const;
49+
void codecTag(uint32_t codec_tag);
50+
51+
// TBD
3252
};
3353

3454
class CodecParameters : public CodecParametersView, public noncopyable

0 commit comments

Comments
 (0)