void OutProgressiveOGG::sendHeader(){
    HTTP_S.Clean(); //make sure no parts of old requests are left in any buffers
    HTTP_S.SetHeader("Content-Type", "video/ogg");
    HTTP_S.protocol = "HTTP/1.0";
    myConn.SendNow(HTTP_S.BuildResponse("200", "OK")); //no SetBody = unknown length - this is intentional, we will stream the entire file
    

    std::map<int, std::deque<std::string> > initData;

    OGG::oggSegment newSegment;
    for (std::set<long unsigned int>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
      parseInit(myMeta.tracks[*it].init,  initData[*it]);
      if (myMeta.tracks[*it].codec == "theora"){ //get size and position of init data for this page.
        pageBuffer[*it].codec = OGG::THEORA;
        pageBuffer[*it].totalFrames = 1; //starts at frame number 1, according to weird offDetectMeta function.
        std::string tempStr = initData[*it][0];
        theora::header tempHead((char *)tempStr.c_str(), 42);
        pageBuffer[*it].split = tempHead.getKFGShift();
        INFO_MSG("got theora KFG shift: %d", pageBuffer[*it].split); //looks OK.
      } else if (myMeta.tracks[*it].codec == "vorbis"){
        pageBuffer[*it].codec = OGG::VORBIS;
        pageBuffer[*it].totalFrames = 0;
        pageBuffer[*it].sampleRate = myMeta.tracks[*it].rate;
        pageBuffer[*it].prevBlockFlag = -1;
        vorbis::header tempHead((char *)initData[*it][0].data(), initData[*it][0].size());
        pageBuffer[*it].blockSize[0] = std::min(tempHead.getBlockSize0(), tempHead.getBlockSize1());
        pageBuffer[*it].blockSize[1] = std::max(tempHead.getBlockSize0(), tempHead.getBlockSize1());
        char audioChannels = tempHead.getAudioChannels(); //?
        vorbis::header tempHead2((char *)initData[*it][2].data(), initData[*it][2].size());        
        pageBuffer[*it].vorbisModes = tempHead2.readModeDeque(audioChannels);//getting modes
      } else if (myMeta.tracks[*it].codec == "opus"){
        pageBuffer[*it].totalFrames = 0; //?
        pageBuffer[*it].codec = OGG::OPUS;
      }
      pageBuffer[*it].clear(OGG::BeginOfStream, 0, *it, 0);   //CREATES a (map)pageBuffer object, *it = id, pagetype=BOS
      newSegment.dataString = initData[*it][0];
      pageBuffer[*it].oggSegments.push_back(newSegment);
      pageBuffer[*it].sendTo(myConn, 0); //granule position of 0
    }
    for (std::set<long unsigned int>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
      newSegment.dataString = initData[*it][1];
      pageBuffer[*it].oggSegments.push_back(newSegment);
      newSegment.dataString = initData[*it][2];
      pageBuffer[*it].oggSegments.push_back(newSegment);
      while (pageBuffer[*it].oggSegments.size()){
        pageBuffer[*it].sendTo(myConn, 0); //granule position of 0
      }
    }
    sentHeader = true;
  }
Example #2
0
    ListNode* reverseBetween(ListNode* head, int m, int n)
    {
        if (m == n)
        {
            return head;
        }

        ListNode dummyHead(-1);
        dummyHead.next = head;
        ListNode *curNode = &dummyHead;
        int count = 1;
        while (count < m)
        {
            curNode = curNode->next;
            count++;
        }

        ListNode tempHead(-1);
        for (int curInd = m; curInd <= n; curInd++)
        {
            ListNode *tempNode = curNode->next;
            curNode->next = curNode->next->next;
            tempNode->next = tempHead.next;
            tempHead.next = tempNode;
        }

        ListNode *curTemp = tempHead.next;
        while (curTemp->next != NULL)
        {
            curTemp = curTemp->next;
        }
        curTemp->next = curNode->next;
        curNode->next = tempHead.next;

        return dummyHead.next;
    }