avformat/rtp: support RGB/BGR for rfc4175

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
Limin Wang 2021-11-24 19:14:17 +08:00
parent 7b55f95f71
commit 522f577d7e
3 changed files with 34 additions and 0 deletions

View File

@ -74,6 +74,26 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
} else { } else {
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
} else if (!strncmp(data->sampling, "RGB", 3)) {
tag = MKTAG('R', 'G', 'B', 24);
if (data->depth == 8) {
data->xinc = 1;
data->pgroup = 3;
pixfmt = AV_PIX_FMT_RGB24;
stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
} else {
return AVERROR_INVALIDDATA;
}
} else if (!strncmp(data->sampling, "BGR", 3)) {
tag = MKTAG('B', 'G', 'R', 24);
if (data->depth == 8) {
data->xinc = 1;
data->pgroup = 3;
pixfmt = AV_PIX_FMT_BGR24;
stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
} else {
return AVERROR_INVALIDDATA;
}
} else { } else {
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }

View File

@ -45,6 +45,14 @@ void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size)
xinc = yinc = 4; xinc = yinc = 4;
pgroup = 6; pgroup = 6;
break; break;
case AV_PIX_FMT_RGB24:
xinc = yinc = 1;
pgroup = 3;
break;
case AV_PIX_FMT_BGR24:
xinc = yinc = 1;
pgroup = 3;
break;
default: default:
return; return;
} }

View File

@ -676,6 +676,12 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int
case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUV420P:
pix_fmt = "YCbCr-4:2:0"; pix_fmt = "YCbCr-4:2:0";
break; break;
case AV_PIX_FMT_RGB24:
pix_fmt = "RGB";
break;
case AV_PIX_FMT_BGR24:
pix_fmt = "BGR";
break;
default: default:
av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n");
return NULL; return NULL;