Exemplo n.º 1
0
int Stream::GetChar(Signal &sig)
{
	char chConv = '\0';
	Codec::Decoder *pDecoder = GetCodec()->GetDecoder();
	if (pDecoder->FollowChar(chConv)) return static_cast<UChar>(chConv);
	for (;;) {
		int ch = DoGetChar(sig);
		if (ch < 0) return ch;
		Codec::Result rtn = pDecoder->FeedChar(static_cast<char>(ch), chConv);
		if (rtn == Codec::RESULT_Complete) {
			break;
		} else if (rtn == Codec::RESULT_Error) {
			sig.SetError(ERR_CodecError, "not a valid character of %s", GetCodec()->GetEncoding());
			return -1;
		}
	}
	return static_cast<UChar>(chConv);
}
Exemplo n.º 2
0
String Stream::ReadChar(Signal &sig)
{
	char chConv = '\0';
	String str;
	Codec::Decoder *pDecoder = GetCodec()->GetDecoder();
	for (;;) {
		int ch = DoGetChar(sig);
		if (ch < 0) break;
		Codec::Result rtn = pDecoder->FeedChar(static_cast<char>(ch), chConv);
		if (rtn == Codec::RESULT_Complete) {
			str += chConv;
			break;
		} else if (rtn == Codec::RESULT_Error) {
			sig.SetError(ERR_CodecError, "not a valid character of %s", GetCodec()->GetEncoding());
			return "";
		}
	}
	while (pDecoder->FollowChar(chConv)) str += chConv;
	return str;
}
Exemplo n.º 3
0
void Stream::PutChar(Signal &sig, char ch)
{
	Codec::Encoder *pEncoder = GetCodec()->GetEncoder();
	if (pEncoder == nullptr) {
		DoPutChar(sig, ch);
	} else {
		char chConv;
		Codec::Result rtn = pEncoder->FeedChar(ch, chConv);
		if (rtn == Codec::RESULT_Complete) {
			DoPutChar(sig, chConv);
			while (pEncoder->FollowChar(chConv)) DoPutChar(sig, chConv);
		} else if (rtn == Codec::RESULT_Error) {
			// nothing to do
		}
	}
}
Exemplo n.º 4
0
}

int MediaPacket::Size() const
{
    return static_cast<int>(pAvPacket_->size);
}

void MediaPacket::Print() const
{
#if LOG_TRADITIONAL
    loginfo("packet: pts=%lu, dts=%lu, stream=%d, codec=%d, size=%lu",
#else
    loginfo("packet: pts={}, dts={}, stream={}, codec={}, size={}",
#endif
        static_cast<unsigned long>(pAvPacket_->pts), static_cast<unsigned long>(pAvPacket_->dts),
        GetStreamType(), GetCodec(), static_cast<unsigned long>(pAvPacket_->size));
        
}

void MediaPacket::Dump(const std::string& _title) const
{
#if LOG_TRADITIONAL
    logdebug("%spts=%lu, dts=%lu, stream=%d, codec=%d, size=%lu", _title.c_str(),
#else
    logdebug("{}pts={}, dts={}, stream={}, codec={}, size={}", _title.c_str(),
#endif
        static_cast<unsigned long>(pAvPacket_->pts), static_cast<unsigned long>(pAvPacket_->dts),
        GetStreamType(), GetCodec(), static_cast<unsigned long>(pAvPacket_->size));
    //PrintMem(Data(), Size());
}