예제 #1
0
XYPOSITION SurfaceImpl::WidthText(Font &font, const char *s, int len)
{
	QFontMetrics metrics(*FontPointer(font), device);
	SetCodec(font);
	QString string = codec->toUnicode(s, len);
	return metrics.width(string);
}
예제 #2
0
void SurfaceImpl::SetFont(Font &font)
{
	if (font.GetID()) {
		GetPainter()->setFont(*FontPointer(font));
		SetCodec(font);
	}
}
예제 #3
0
bool Stream_File::OpenStderr()
{
	_fp = stderr;
	_fileName = "stderr", SetReadable(false), SetWritable(true);
	SetCodec(Codec::CreateCodec(_sig, OAL::GetEncodingForConsole(), true, false));
	return true;
}
예제 #4
0
int TestRealEcho::NObjDirectCall::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    typedef Domain::NamedObject QMocSuperClass;
    _id = QMocSuperClass::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: Init((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 1: SetCodec((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 2: SetSourceFile((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 3: SetSourceGen((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: WaitInterfaceReady((*reinterpret_cast< DRI::IAsyncCmd*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 5: Run((*reinterpret_cast< DRI::IAsyncCmd*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 6;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = m_minRtpPort; break;
        case 1: *reinterpret_cast< int*>(_v) = m_maxRtpPort; break;
        case 2: *reinterpret_cast< QString*>(_v) = m_localHost; break;
        case 3: *reinterpret_cast< int*>(_v) = m_channel; break;
        case 4: *reinterpret_cast< QString*>(_v) = m_outFile; break;
        case 5: *reinterpret_cast< bool*>(_v) = m_waveOut; break;
        case 6: *reinterpret_cast< QString*>(_v) = CodecInfo(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: m_minRtpPort = *reinterpret_cast< int*>(_v); break;
        case 1: m_maxRtpPort = *reinterpret_cast< int*>(_v); break;
        case 2: m_localHost = *reinterpret_cast< QString*>(_v); break;
        case 3: m_channel = *reinterpret_cast< int*>(_v); break;
        case 4: m_outFile = *reinterpret_cast< QString*>(_v); break;
        case 5: m_waveOut = *reinterpret_cast< bool*>(_v); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
예제 #5
0
int EncoderMFC::Initialize(int width, int height,int codec,float rate,int bitrate,int in_bufs,int out_bufs, int stream_b_size){

    if(state!=MFC_ST_OPEN)
        return -1;

    if(SetFormat(width,height)<0)
        return -1;

    if(SetCodec(codec,stream_b_size)<0)
        return -1;

    SetRate(rate);

    if(bitrate>0)
        SetBitRate(bitrate);

    if(InitBuffers(DIR_IN,in_bufs)<0)
        return -1;

    if(InitBuffers(DIR_OUT,out_bufs)<0)
        return -1;


    for (int bi=0;bi<out_bufs;bi++){


        struct v4l2_buffer buf;
        struct v4l2_plane planes[MFC_MAX_PLANES];

        buf.type = io_dir_to_type(DIR_OUT);
        buf.memory = V4L2_MEMORY_MMAP;
        buf.m.planes = planes;
        buf.length = NPPBuf[DIR_OUT];

        buf.index=bi;


        for (u_int i = 0; i < NPPBuf[DIR_OUT]; i++){
            planes[i].length=PlanesLen[DIR_OUT][i];
            planes[i].bytesused=0;
            planes[i].m.userptr=(u_long)BufAddr[DIR_OUT][bi][i];
        }

        int ret = ioctl(fd, VIDIOC_QBUF, &buf);
        if (ret != 0) {
            printf("\nEncoderMFC: Init, Queue buffer %d error! %s\n",buf.index,strerror(errno));
        }

    }

    BufInx[DIR_OUT]=0;

    state=MFC_ST_OK;
    return 0;

}
예제 #6
0
bool Stream_File::OpenStderr()
{
	Close();
	_hFile = ::GetStdHandle(STD_ERROR_HANDLE);
	if (_hFile != INVALID_HANDLE_VALUE) {
		_fileName = "stderr", SetReadable(false), SetWritable(true);
		SetCodec(Codec::CreateCodec(_sig, OAL::GetEncodingForConsole(), true, true));
	}
	return true;
}
예제 #7
0
void SurfaceImpl::MeasureWidths(Font &font,
                                const char *s,
                                int len,
                                XYPOSITION *positions)
{
	if (!font.GetID())
		return;
	SetCodec(font);
	QString su = codec->toUnicode(s, len);
	QTextLayout tlay(su, *FontPointer(font));
	tlay.beginLayout();
	QTextLine tl = tlay.createLine();
	tlay.endLayout();
	if (unicodeMode) {
		int fit = su.size();
		int ui=0;
		const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
		int i=0;
		while (ui<fit) {
			size_t lenChar = utf8LengthFromLead(us[i]);
			size_t codeUnits = (lenChar < 4) ? 1 : 2;
			qreal xPosition = tl.cursorToX(ui+codeUnits);
			for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
				positions[i++] = qRound(xPosition);
			}
			ui += codeUnits;
		}
		int lastPos = 0;
		if (i > 0)
			lastPos = positions[i-1];
		while (i<len) {
			positions[i++] = lastPos;
		}
	} else if (codePage) {
		// DBCS
		int ui = 0;
		for (int i=0; i<len;) {
			size_t lenChar = Platform::IsDBCSLeadByte(codePage, s[i]) ? 2 : 1;
			qreal xPosition = tl.cursorToX(ui+1);
			for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
				positions[i++] = qRound(xPosition);
			}
			ui++;
		}
	} else {
		// Single byte encoding
		for (int i=0; i<len; i++) {
			positions[i] = qRound(tl.cursorToX(i+1));
		}
	}
}
예제 #8
0
MediaPacket::MediaPacket(IN const AVStream& _avStream, IN const AVPacket* _pAvPacket)
{
    // save codec pointer
    pAvCodecPar_ = _avStream.codecpar;
    enum AVMediaType stream = pAvCodecPar_->codec_type;
    if (stream != AVMEDIA_TYPE_AUDIO && stream != AVMEDIA_TYPE_VIDEO) {
        stream = AVMEDIA_TYPE_DATA;
    }
    SetStreamType(stream);
    SetCodec(pAvCodecPar_->codec_id);
    Width(pAvCodecPar_->width);
    Height(pAvCodecPar_->height);
    SampleRate(pAvCodecPar_->sample_rate);
    Channels(pAvCodecPar_->channels);

    // copy packet
    pAvPacket_ = const_cast<AVPacket*>(_pAvPacket);
}
예제 #9
0
//测试兼主函数
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    SetCodec();
    qDebug()<<QCoreApplication::applicationDirPath();
    //单元测试方框父类

//    FatherBlock testFatherBlock;
//    testFatherBlock.InitBlocksList();
//    testFatherBlock.show();
//       QBitArray newstatus(16);
//       newstatus.setBit(0,true);
//       newstatus.setBit(1,true);
//       newstatus.setBit(5,true);
//       newstatus.setBit(6,true);
//       qDebug()<<testFatherBlock.addStatus(newstatus);

//       QBitArray newstatus1(16);
//       newstatus1.setBit(1,true);
//       newstatus1.setBit(4,true);
//       newstatus1.setBit(5,true);
//       newstatus1.setBit(8,true);
//       qDebug()<<testFatherBlock.addStatus(newstatus1);


    //单元测试游戏窗体
    GameWindow w;
    w.show();

 // TestUnit for Ranking
//    GameRankingList TestGame;
    //TestItem
//    GameRankingItem newItem("testgame","testUser",100);
//    GameRankingItem newItem2(newItem);
//    qDebug()<<newItem.GetItemstr()<<"Item1";
//    qDebug()<<newItem2.GetItemstr()<<"Item2";
//    TestList
//    for(int i = 0;i<10;i++)
//    {
//        TestGame.AddGameRecord("TestUser",qrand() % 12);
//    }
//    qDebug()<<TestGame.SaveAsFile("TestRecord.txt");
    //TestGame.InitWithFile("TestRecord.txt");
//    QList<GameRankingItem> theList = TestGame.GetItemsList();
//    for(int i = 0;i<theList.count();i++)
//    {
//        qDebug()<<theList[i].GetMark();
//    }


//    GameRankingList::SortListbyMark(theList);
//     qDebug()<<"----------------------------";
//    for(int i = 0;i<theList.count();i++)
//    {
//        qDebug()<<theList[i].GetMark();
//    }



  //TestForRankingForm
//    GameRankForm theTestForm;
//    for(int i = 0;i<10;i++)
//    {
//        theTestForm.AddNewGameRecord("TestUser"+QString::number(i),qrand() % 12);
//    }
//    theTestForm.RefreshRankList();
//    theTestForm.show();



    return a.exec();
}
예제 #10
0
MediaPacket::MediaPacket(IN FeedFrame & feedFrame) {
        
        AVCodecParameters *param = avcodec_parameters_alloc();
        shouldFreeAvCodecParameters = true;
        enum AVCodecID codecId;
        switch(feedFrame.type_) {
                case ReceiverType::H264 :
                        stream_ = AVMEDIA_TYPE_VIDEO;
                        codecId = AV_CODEC_ID_H264;
                        break;
                case ReceiverType::H265 :
                        stream_ = AVMEDIA_TYPE_VIDEO;
                        codecId = AV_CODEC_ID_HEVC;
                        break;
                case ReceiverType::G711A :
                        stream_ = AVMEDIA_TYPE_AUDIO;
                        codecId = AV_CODEC_ID_PCM_ALAW;
                        break;
                case ReceiverType::G711U :
                        stream_ = AVMEDIA_TYPE_AUDIO;
                        codecId = AV_CODEC_ID_PCM_MULAW;
                        break;
                case ReceiverType::PCMS16E :
                        stream_ = AVMEDIA_TYPE_AUDIO;
                        codecId = AV_CODEC_ID_PCM_S16LE;
                        break;
                case ReceiverType::AACNoAdts :
                case ReceiverType::AACAdts :
                        stream_ = AVMEDIA_TYPE_AUDIO;
                        codecId = AV_CODEC_ID_AAC;
                        break;
                default:
                        codecId = AV_CODEC_ID_NONE;
        }
        SetCodec(codecId);
        
        switch(feedFrame.type_) {
                case ReceiverType::G711A :
                case ReceiverType::PCMS16E :
                case ReceiverType::G711U :
                        param->channels = 1;
                        param->channel_layout = AV_CH_LAYOUT_MONO;
                        param->sample_rate = 8000;
                        param->codec_id = codecId;
                        param->codec_type = AVMEDIA_TYPE_AUDIO;
                        param->format = AV_SAMPLE_FMT_S16;
                        param->bits_per_coded_sample = 8;
                        param->bits_per_raw_sample = 16;
                        if (ReceiverType::PCMS16E == feedFrame.type_)
                                param->bits_per_coded_sample = 16;
                        break;
                default:
                        codecId = AV_CODEC_ID_NONE;
        }
        pAvCodecPar_ = param;
        
        AVPacket* pAvPacket = av_packet_alloc();
        av_init_packet(pAvPacket);
        pAvPacket->data = reinterpret_cast<uint8_t *>(feedFrame.data_.data());
        pAvPacket->size = feedFrame.data_.size();
        pAvPacket->pts = feedFrame.nPts_;
        pAvPacket->dts = feedFrame.nDts_;
        pAvPacket_ = const_cast<AVPacket*>(pAvPacket);
}