Commit 5e145473 authored by François Grisez's avatar François Grisez

MediaCodec: display the MediaFormat content after configuring and on format changing notification.

parent 14c39daf
......@@ -131,6 +131,11 @@ MediaCodecDecoder::Status MediaCodecDecoder::fetch(mblk_t *&frame) {
oBufidx = AMediaCodec_dequeueOutputBuffer(_impl, &info, _timeoutUs);
if (oBufidx == AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED || oBufidx == AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED) {
ms_message("MediaCodecDecoder: %s", codecInfoToString(oBufidx).c_str());
if (oBufidx == AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED) {
AMediaFormat *format = AMediaCodec_getOutputFormat(_impl);
ms_message("MediaCodecDecoder: new format:\n%s", AMediaFormat_toString(format));
AMediaFormat_delete(format);
}
oBufidx = AMediaCodec_dequeueOutputBuffer(_impl, &info, _timeoutUs);
}
......@@ -176,7 +181,7 @@ AMediaFormat *MediaCodecDecoder::createFormat(const std::string &mime) const {
void MediaCodecDecoder::startImpl() {
media_status_t status = AMEDIA_OK;
ostringstream errMsg;
ms_message("MediaCodecDecoder: starting decoder");
ms_message("MediaCodecDecoder: starting decoder with following parameters:\n%s", AMediaFormat_toString(_format));
if ((status = AMediaCodec_configure(_impl, _format, nullptr, nullptr, 0)) != AMEDIA_OK) {
errMsg << "configuration failure: " << int(status);
throw runtime_error(errMsg.str());
......@@ -186,6 +191,8 @@ void MediaCodecDecoder::startImpl() {
errMsg << "starting failure: " << int(status);
throw runtime_error(errMsg.str());
}
ms_message("MediaCodecDecoder: decoder successfully started. In-force parameters:\n%s", AMediaFormat_toString(_format));
}
void MediaCodecDecoder::stopImpl() {
......
......@@ -192,6 +192,9 @@ bool MediaCodecEncoder::fetch(MSQueue *encodedData) {
ssize_t obufidx = AMediaCodec_dequeueOutputBuffer(_impl, &info, _timeoutUs);
if (obufidx == AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED) {
ms_message("MediaCodecEncoder: output format has changed.");
AMediaFormat *format = AMediaCodec_getOutputFormat(_impl);
ms_message("MediaCodecEncoder: new output format:\n%s", AMediaFormat_toString(format));
AMediaFormat_delete(format);
obufidx = AMediaCodec_dequeueOutputBuffer(_impl, &info, _timeoutUs);
}
if (obufidx < 0) {
......@@ -231,8 +234,7 @@ void MediaCodecEncoder::createImpl() {
void MediaCodecEncoder::configureImpl() {
AMediaFormat *format = createMediaFormat();
ms_message("MediaCodecEncoder: configuring MediaCodec with the following parameters:");
ms_message("%s", getMediaForamtAsString().str().c_str());
ms_message("MediaCodecEncoder: configuring MediaCodec with the following parameters:\n%s", AMediaFormat_toString(format));
media_status_t status = AMediaCodec_configure(_impl, format, nullptr, nullptr, AMEDIACODEC_CONFIGURE_FLAG_ENCODE);
AMediaFormat_delete(format);
......@@ -241,7 +243,9 @@ void MediaCodecEncoder::configureImpl() {
throw runtime_error("could not configure encoder.");
}
ms_message("MediaCodecEncoder: encoder successfully configured.");
format = AMediaCodec_getOutputFormat(_impl);
ms_message("MediaCodecEncoder: encoder successfully configured. In-force parameters:\n%s", AMediaFormat_toString(format));
AMediaFormat_delete(format);
}
AMediaFormat *MediaCodecEncoder::createMediaFormat() const {
......@@ -259,26 +263,4 @@ AMediaFormat *MediaCodecEncoder::createMediaFormat() const {
return format;
}
std::ostringstream MediaCodecEncoder::getMediaForamtAsString() const {
ostringstream os;
os << "\tmime: " << _mime << endl;
os.unsetf(ios::basefield);
os.setf(ios::hex);
os.setf(ios::showbase);
os << "\tcolor-format: " << _colorFormat << endl;
os.unsetf(ios::basefield);
os.setf(ios::dec);
os.unsetf(ios::showbase);
os << "\tvideo size: " << _vsize.width << "x" << _vsize.height << endl;
os << "\tframe-rate: " << _fps << " fps" << endl;
os << "\tbitrate: " << _bitrate << " b/s" << endl;
os << "\tbitrate-mode: " << _bitrateMode << endl;
os << "\ti-frame-intervale: " << _iFrameInterval << endl;
os << "\tlatency: " << _encodingLatency << endl;
os << "\tpriority: " << _priority << endl;
return os;
}
} // namespace mediastreamer
......@@ -55,7 +55,6 @@ protected:
void createImpl();
void configureImpl();
virtual AMediaFormat *createMediaFormat() const;
virtual std::ostringstream getMediaForamtAsString() const;
std::unique_ptr<H26xParameterSetsInserter> _psInserter;
MSVideoSize _vsize;
......
......@@ -51,12 +51,6 @@ private:
return format;
}
std::ostringstream getMediaForamtAsString() const override {
std::ostringstream os = MediaCodecEncoder::getMediaForamtAsString();
os << "\tprofile: " << _profile << std::endl;
return os;
}
static const int32_t _profile = 1; // AVCProfileBaseline
static const int32_t _level = 512; // AVCLevel31
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment