void Psmf::setStreamNum(int num) { currentStreamNum = num; if (!isValidCurrentStreamNumber()) return; PsmfStreamMap::iterator iter = streamMap.find(currentStreamNum); if (iter == streamMap.end()) return; int type = iter->second->type; int channel = iter->second->channel; switch (type) { case PSMF_AVC_STREAM: if (currentVideoStreamNum != num) { // TODO: Tell video mediaengine or something about channel. currentVideoStreamNum = num; } break; case PSMF_ATRAC_STREAM: case PSMF_PCM_STREAM: if (currentAudioStreamNum != num) { // TODO: Tell audio mediaengine or something about channel. currentAudioStreamNum = num; } break; } }
bool Psmf::setStreamWithType(int type, int channel) { for (PsmfStreamMap::iterator iter = streamMap.begin(); iter != streamMap.end(); ++iter) { if (iter->second->type == type && iter->second->channel == channel) { setStreamNum(iter->first); return true; } } return false; }
void Psmf::DoState(PointerWrap &p) { p.Do(magic); p.Do(version); p.Do(streamOffset); p.Do(streamSize); p.Do(headerOffset); p.Do(streamDataTotalSize); p.Do(presentationStartTime); p.Do(presentationEndTime); p.Do(streamDataNextBlockSize); p.Do(streamDataNextInnerBlockSize); p.Do(numStreams); p.Do(currentStreamNum); p.Do(currentAudioStreamNum); p.Do(currentVideoStreamNum); p.Do(EPMapOffset); p.Do(EPMapEntriesNum); p.Do(videoWidth); p.Do(videoHeight); p.Do(audioChannels); p.Do(audioFrequency); int n = (int) streamMap.size(); p.Do(n); if (p.mode == p.MODE_READ) { // Already empty, if we're reading this is brand new. for (int i = 0; i < n; ++i) { int key; p.Do(key); PsmfStream *stream = new PsmfStream(0, 0); stream->DoState(p); streamMap[key] = stream; } } else { for (auto it = streamMap.begin(), end = streamMap.end(); it != end; ++it) { p.Do(it->first); it->second->DoState(p); } } p.DoMarker("Psmf"); }