当前位置: 首页>>代码示例>>C++>>正文


C++ AttributeList::contains方法代码示例

本文整理汇总了C++中AttributeList::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeList::contains方法的具体用法?C++ AttributeList::contains怎么用?C++ AttributeList::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AttributeList的用法示例。


在下文中一共展示了AttributeList::contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleMessage

/*
 * The example session from Pebble SDK (pebble transcribe --phone jolla -vvvv "pebble sdk test 4")
DEBUG:libpebble2.communication:<- 00292af8010000000001120001011d00312e327263310000000000000000000000000000803e00000032044001
DEBUG:libpebble2.communication:<- VoiceControlCommand(command=Command.SessionSetup, flags=0, data=SessionSetupCommand(session_type=SessionType.Dictation, session_id=18, attributes=AttributeList(count=1, dictionary=[Attribute(id=AttributeType.SpeexEncoderInfo, length=29, data=SpeexEncoderInfo(version=1.2rc1, sample_rate=16000, bit_rate=12800, bitstream_version=4, frame_size=320))])))
DEBUG:libpebble2.voice:
DEBUG:libpebble2.voice:)
DEBUG:libpebble2.communication:-> VoiceControlResult(command=None, flags=0, data=SessionSetupResult(session_type=SessionType.Dictation, result=SetupResult.Success))
DEBUG:libpebble2.communication:-> 00072af801000000000100
DEBUG:libpebble2.communication:<- 00252710021200012025ce7530001b366cd9b1c09b364c62d2233fe25a16468763d58d6f493a1051f3
DEBUG:libpebble2.communication:<- AudioStream(packet_id=2, session_id=18, data=DataTransfer(frame_count=1, frames=[EncoderFrame(data=25ce7530001b366cd9b1c09b364c62d223...)]))
DEBUG:libpebble2.communication:<- 00252710021200012025458925e3ac89339017d185d97e754b91057ceccbb02340e485f2c93867ba72
DEBUG:libpebble2.communication:<- AudioStream(packet_id=2, session_id=18, data=DataTransfer(frame_count=1, frames=[EncoderFrame(data=25458925e3ac89339017d185d97e754b91...)]))
DEBUG:libpebble2.communication:<- 00252710021200012025ce45157c0ce4fbd80e69f812582aa36945040a247e292755e81139396a3a71
DEBUG:libpebble2.communication:<- AudioStream(packet_id=2, session_id=18, data=DataTransfer(frame_count=1, frames=[EncoderFrame(data=25ce45157c0ce4fbd80e69f812582aa369...)]))
DEBUG:libpebble2.communication:<- 00032710031200
DEBUG:libpebble2.communication:<- AudioStream(packet_id=3, session_id=18, data=StopTransfer())
DEBUG:libpebble2.communication:-> AudioStream(packet_id=None, session_id=18, data=StopTransfer())
DEBUG:libpebble2.communication:-> 00032710031200
DEBUG:libpebble2.voice:)
DEBUG:libpebble2.communication:-> VoiceControlResult(command=None, flags=0, data=DictationResult(session_id=18, result=TranscriptionResult.Success, attributes=AttributeList(count=None, dictionary=[Attribute(id=AttributeType.Transcription, length=None, data=Transcription(type=None, transcription=SentenceList(count=None, sentences=[Sentence(count=None, words=[Word(confidence=100, length=None, data=706562626c65), Word(confidence=100, length=None, data=73646b), Word(confidence=100, length=None, data=74657374), Word(confidence=100, length=None, data=34)])])))])))
DEBUG:libpebble2.communication:-> 002a2af8020000000012000001021e0001010400640600706562626c6564030073646b6404007465737464010034
DEBUG:libpebble2.voice:Invalidating session 18 on send
DEBUG:libpebble2.voice:Invalidating session 0 on stop
 * serialized raw framed packet of result response
 * 002a 2af8 02 00000000 1200 00 01 02 1e00 01 01 0400 64 0600 706562626c65 64 0300 73646b 64 0400 74657374 64 0100 34
 * 002a Framing - length
 * 2af8 Framing - endpoint
 * 02 - DictationResult command
 * 00000000 - flags
 * 1200 - sessionId (LE)
 * 00 - Success (result)
 * 01 - attributes:count
 * 02 - attribute:type - Transcription
 * 1e00 - attribute:length (LE)
 * 01 - Transcription Type - SentenceList
 * 01 - SentenceList:count
 * 0400 - Sentence:count (LE)
 * 64 - confidence
 * 0600 - length
 * 706562626c65 - data
 * ...
[D] VoiceEndpoint::sendDictationResults:207 - Sending session recognition result 0 for session 27 with content 1 for app QUuid("{00000000-0000-0000-0000-000000000000}") true
[D] VoiceEndpoint::AttributeList::writerWrite:305 - Writing attribute "Attribute(type=2, Transcription(type=SentenceList, SentenceList(count=1, sentences=[Sentence(count=1, words=[Word(confidence=100, word=Timeout)])])))"
[D] VoiceEndpoint::Attribute::writerWrite:352 - Serializing Transcription 0 1
[D] VoiceEndpoint::sendDictationResults:222 - Sent "0200000000001b0001020f000101010064080054696d656f757400"
 * Serialized unframed voice control packet
 * 02 00000000 0300 00 01 02 0f00 01 01 0100 64 0800 54696d656f757400
 * 02   - DictationResult
 * 0300 - sessionId
 * 00   - Success (result)
 * 01   - AttributeList:count
 * 02   - Attibute:Type - Transcription
 * 0f00 - Attribute:Length
 * 01   - Transcription:Type - SentenceList
 * 01   - SentenceList:Count
 * 01   - Sentence:Count
 * 64   - Word:Confidence
 * 0800 - Word:Length
 * 54696d656f757400 - data (Timeout\0)
 */
void VoiceEndpoint::handleMessage(const QByteArray &data)
{
    WatchDataReader reader(data);
    quint8 cmd = reader.read<quint8>();

    if(cmd == CmdSessionSetup) {
        quint32 flags = reader.readLE<quint32>();
        quint8 sessType = reader.read<quint8>();
        quint16 sesId = reader.readLE<quint16>();
        if(sesId > 0 && m_sessId == 0) {
            AttributeList list = readAttributes(reader);
            if(((flags & FlagAppInitiated)!=0) == list.contains(AttAppUuid)) {
                if(sessType == SesDictation) {
                    qDebug() << "Got Dictation session request" << sesId;
                    if(list.count > 0 && list.contains(AttSpeexInfo)) {
                        m_sessId = sesId;
                        m_sesType = (SessionType)sessType;
                        m_appUuid = list.attByType(AttAppUuid).uuid;
                        m_codec = list.attByType(AttSpeexInfo).speexInfo;
                        qDebug() << "Session Setup Request" << ((flags&FlagAppInitiated)?list.attByType(AttAppUuid).uuid.toString():"");
                        emit sessionSetupRequest(m_appUuid,m_codec);
                        m_sesPhase = PhSetupRequest;
                        m_sesTimer = startTimer(4000);
                    } else {
                        qWarning() << "Invalid attribute set for dictation request" << list.count;
                    }
                } else if(sessType == SesCommand) {
                    qDebug() << "Got Voice Command session request which is rather unexpected";
                } else {
                    qWarning() << "Unknown Session type" << sessType << data.toHex();
                }
            } else {
                qWarning() << "Invalid Flags/Attributes combination" << flags;
            }
        } else {
            qWarning() << "Invalid sessionID for session setup" << sesId << m_sessId << data.toHex();
        }
    } else {
        qWarning() << "Unknown command" << data.toHex();
    }
//.........这里部分代码省略.........
开发者ID:0312birdzhang,项目名称:rockpool,代码行数:101,代码来源:voiceendpoint.cpp


注:本文中的AttributeList::contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。