Example #1
0
  int OutputProcessor::packageAudio(unsigned char* inBuff, int inBuffLen,
      unsigned char* outBuff, long int pts) {

    if (audioPackager == 0) {
      ELOG_DEBUG("No se ha inicializado el codec de output audio RTP");
      return -1;
    }


    timeval time;
    gettimeofday(&time, NULL);
    long millis = (time.tv_sec * 1000) + (time.tv_usec / 1000);

    RtpHeader head;
    head.setSeqNumber(audioSeqnum_++);
//    head.setTimestamp(millis*8);
    head.setMarker(1);
    if (pts==0){
//      head.setTimestamp(audioSeqnum_*160);
      head.setTimestamp(av_rescale(audioSeqnum_, (mediaInfo.audioCodec.sampleRate/1000), 1));
    }else{
//      head.setTimestamp(pts*8);
      head.setTimestamp(av_rescale(pts, mediaInfo.audioCodec.sampleRate,1000));
    }
    head.setSSRC(44444);
    head.setPayloadType(mediaInfo.rtpAudioInfo.PT);

//    memcpy (rtpAudioBuffer_, &head, head.getHeaderLength());
//    memcpy(&rtpAudioBuffer_[head.getHeaderLength()], inBuff, inBuffLen);
    memcpy (outBuff, &head, head.getHeaderLength());
    memcpy(&outBuff[head.getHeaderLength()], inBuff, inBuffLen);
    //			sink_->sendData(rtpBuffer_, l);
    //	rtpReceiver_->receiveRtpData(rtpBuffer_, (inBuffLen + RTP_HEADER_LEN));
    return (inBuffLen+head.getHeaderLength());
  }
Example #2
0
  int OutputProcessor::packageVideo(unsigned char* inBuff, int buffSize, unsigned char* outBuff, 
      long int pts) {
    if (videoPackager == 0) {
      ELOG_DEBUG("No se ha inicailizado el codec de output vĂ­deo RTP");
      return -1;
    }

    //    ELOG_DEBUG("To packetize %u", buffSize);
    if (buffSize <= 0)
      return -1;
    RtpVP8Fragmenter frag(inBuff, buffSize, 1100);
    bool lastFrame = false;
    unsigned int outlen = 0;
    timeval time;
    gettimeofday(&time, NULL);
    long millis = (time.tv_sec * 1000) + (time.tv_usec / 1000);
    //		timestamp_ += 90000 / mediaInfo.videoCodec.frameRate;

          //int64_t pts = av_rescale(lastPts_, 1000000, (long int)video_time_base_);
    do {
      outlen = 0;
      frag.getPacket(outBuff, &outlen, &lastFrame);
      RtpHeader rtpHeader;
      rtpHeader.setMarker(lastFrame?1:0);
      rtpHeader.setSeqNumber(seqnum_++);
      if (pts==0){
          rtpHeader.setTimestamp(av_rescale(millis, 90000, 1000)); 
      }else{
          rtpHeader.setTimestamp(av_rescale(pts, 90000, 1000)); 
        
      }
      rtpHeader.setSSRC(55543);
      rtpHeader.setPayloadType(100);
      memcpy(rtpBuffer_, &rtpHeader, rtpHeader.getHeaderLength());
      memcpy(&rtpBuffer_[rtpHeader.getHeaderLength()],outBuff, outlen);

      int l = outlen + rtpHeader.getHeaderLength();
      //			sink_->sendData(rtpBuffer_, l);
      rtpReceiver_->receiveRtpData(rtpBuffer_, l);
    } while (!lastFrame);

    return 0;
  }