Beispiel #1
0
/*
 * rtsp_setup_redirect()
 * Sets up URLs, does the connect for redirects.  Need to handle
 * 300 case (multiple choices).  Imagine that if we had that, we'd just
 * loop through the body until we found a server that we could connect
 * with.
 */
int rtsp_setup_redirect (rtsp_client_t *info)
{
  rtsp_decode_t *decode;
  int ret;
  if (info->decode_response == NULL)
    return (-1);

  info->redirect_count++;
  if (info->redirect_count > 5) 
    return (-1);

  decode = info->decode_response;
  if (decode->location == NULL)
    return (-1);
  
  if (info->orig_url == NULL) {
    info->orig_url = info->url;
    info->url = NULL;
  } else {
    CHECK_AND_FREE(info->url);
  }

  CHECK_AND_FREE(info->server_name);
  rtsp_close_socket(info);

  ret = rtsp_dissect_url(info, decode->location);
  if (ret != 0) return (ret);
  
  return (rtsp_create_socket(info));

}
Beispiel #2
0
/* 
 * attempts to match the session url with  
 * content_base/url or session_name/url
 * if content base and url overlap, or if session_name and 
 * url overlap, remove the overlap and attempt to match again
 * return 1 if matched, 0 otherwise
 */
int rtsp_is_url_my_stream (rtsp_session_t *session,
			   const char *url,
			   const char *content_base,
			   const char *session_name)
{ 
  char *session_url = session->url;
  const char *end;
  int is_match = 0;

  end = my_strrstr(session_url, url); 
  if (end != NULL  || strcmp(url,"*") == 0) {
    if (strncmp(session_url, content_base,
		strlen(session_url) - strlen(end)) == 0
	|| strncmp(session_url, session_name, 
		   strlen(session_url) - strlen(end)) == 0) {
      is_match = 1;
    }
    else {
      /* url isn't contained in the session_url */
      /* check if there is an overlap */
      char *str1 = rm_rtsp_overlap(url, content_base);
      char *str2 = rm_rtsp_overlap(url, session_name);
      if ((str1 != NULL && strcmp(session_url, str1) == 0 )
	  || (str2 != NULL && strcmp(session_url, str2) == 0))
	is_match = 1;
      CHECK_AND_FREE(str1);
      CHECK_AND_FREE(str2);
    }
  }
  return (is_match);
}
Beispiel #3
0
void CFfmpegVideoEncoder::StopEncoder (void)
{
  ffmpeg_interface_lock();
  if (m_avctx != NULL) {
    avcodec_close(m_avctx);
    av_freep(&m_avctx);
  }
  ffmpeg_interface_unlock();
  CHECK_AND_FREE(m_vopBuffer);
  CHECK_AND_FREE(m_YUV);
  CHECK_AND_FREE(m_picture);
#ifdef OUTPUT_RAW
  if (m_outfile) {
    fclose(m_outfile);
  }
#endif
  if (m_push != NULL) {
    delete m_push;
    m_push = NULL;
  }
  while (m_pts_queue != NULL) {
    pts_queue_t *pts;
    pts = m_pts_queue->next;
    CHECK_AND_FREE(m_pts_queue->frameBuffer);
    free(m_pts_queue);
    m_pts_queue = pts;
  }
}
Beispiel #4
0
static void href_close (codec_data_t *ptr)
{
    href_codec_t *href = (href_codec_t *)ptr;
    CHECK_AND_FREE(href->m_base_url);
    CHECK_AND_FREE(href->m_url);
    free(href);
}
bool CMp4EncVideoByteStream::start_next_frame (uint8_t **buffer, 
					       uint32_t *buflen,
					       frame_timestamp_t *ts,
					       void **ud)
{
  bool ret = CMp4VideoByteStream::start_next_frame(buffer, buflen, ts, ud);
  u_int8_t *temp_buffer = NULL;
  u_int32_t temp_this_frame_size = 0;
  ismacryp_rc_t ismacryprc;
  ismacryprc = ismacrypDecryptSampleRemoveHeader(m_ismaCryptSId, 
					*buflen,
					*buffer,
					&temp_this_frame_size,
					&temp_buffer);

  if (ismacryprc != ismacryp_rc_ok ) {
    mp4f_message(LOG_ERR, "%s  2. decrypt error code:  %u" ,
	       m_name, ismacryprc);
    CHECK_AND_FREE(temp_buffer);
    // can't copy anything to buffer in this case.
    return ret; 
  }

  *buflen = temp_this_frame_size;
  memset(*buffer, 0, *buflen * sizeof(u_int8_t));
  memcpy(*buffer, temp_buffer, temp_this_frame_size);
  CHECK_AND_FREE(temp_buffer);
  return ret; 
}
Beispiel #6
0
extern "C" bool MP4AV_Rfc3016Hinter(
    MP4FileHandle mp4File,
    MP4TrackId mediaTrackId,
    u_int16_t maxPayloadSize)
{
    u_int32_t numSamples = MP4GetTrackNumberOfSamples(mp4File, mediaTrackId);
    u_int32_t maxSampleSize = MP4GetTrackMaxSampleSize(mp4File, mediaTrackId);

    if (numSamples == 0 || maxSampleSize == 0) {
        return false;
    }

    MP4TrackId hintTrackId =
        MP4AV_Rfc3016_HintTrackCreate(mp4File, mediaTrackId);

    if (hintTrackId == MP4_INVALID_TRACK_ID) {
        return false;
    }

    u_int8_t* pSampleBuffer = (u_int8_t*)malloc(maxSampleSize);
    if (pSampleBuffer == NULL) {
        MP4DeleteTrack(mp4File, hintTrackId);
        return false;
    }

    for (MP4SampleId sampleId = 1; sampleId <= numSamples; sampleId++) {
        u_int32_t sampleSize = maxSampleSize;
        MP4Timestamp startTime;
        MP4Duration duration;
        MP4Duration renderingOffset;
        bool isSyncSample;

        bool rc = MP4ReadSample(
                      mp4File, mediaTrackId, sampleId,
                      &pSampleBuffer, &sampleSize,
                      &startTime, &duration,
                      &renderingOffset, &isSyncSample);

        if (rc == false ||
                MP4AV_Rfc3016_HintAddSample(mp4File,
                                            hintTrackId,
                                            sampleId,
                                            pSampleBuffer,
                                            sampleSize,
                                            duration,
                                            renderingOffset,
                                            isSyncSample,
                                            maxPayloadSize) == false) {
            MP4DeleteTrack(mp4File, hintTrackId);
            CHECK_AND_FREE(pSampleBuffer);
            return false;
        }
    }
    CHECK_AND_FREE(pSampleBuffer);

    return true;
}
Beispiel #7
0
void free_req_cmd(jsonrpc_req_cmd_t* req_cmd)
{
	if(req_cmd) {
		CHECK_AND_FREE(req_cmd->conn.s);
		CHECK_AND_FREE(req_cmd->method.s);
		CHECK_AND_FREE(req_cmd->params.s);
		CHECK_AND_FREE(req_cmd->route.s);
		shm_free(req_cmd);
	}
}
Beispiel #8
0
static void free_x264_frame (void *ifptr)
{
  h264_media_frame_t *mf = (h264_media_frame_t *)ifptr;

  if (mf != NULL) {
    CHECK_AND_FREE(mf->buffer);
    CHECK_AND_FREE(mf->nal_bufs);
    free(mf);
  }
}
void CFfmpegVideoEncoder::Stop()
{
  avcodec_close(m_avctx);
  CHECK_AND_FREE(m_YUV);
  CHECK_AND_FREE(m_picture);
  CHECK_AND_FREE(m_avctx);
#ifdef OUTPUT_RAW
  if (m_outfile) {
    fclose(m_outfile);
  }
#endif
	  
}
// Audio encoding main process
int CAudioEncoder::ThreadMain(void) 
{
  CMsg* pMsg;
  bool stop = false;

  debug_message("audio encoder thread %s %s %s start", Profile()->GetName(),
		Profile()->GetStringValue(CFG_AUDIO_ENCODER), 
		Profile()->GetStringValue(CFG_AUDIO_ENCODING));

  while (stop == false && SDL_SemWait(m_myMsgQueueSemaphore) == 0) {
    pMsg = m_myMsgQueue.get_message();
    if (pMsg != NULL) {
      switch (pMsg->get_value()) {
      case MSG_NODE_STOP_THREAD:
	DoStopAudio();
	stop = true;
	break;
      case MSG_NODE_START:
	// DoStartTransmit();  Anything ?
	break;
      case MSG_NODE_STOP:
	DoStopAudio();
	break;
      case MSG_SINK_FRAME: {
	uint32_t dontcare;
	CMediaFrame *mf = (CMediaFrame*)pMsg->get_message(dontcare);
	if (m_stop_thread == false)
	  ProcessAudioFrame(mf);
	if (mf->RemoveReference()) {
	  delete mf;
	}
	break;
      }
      }
      
      delete pMsg;
    }
  }
  while ((pMsg = m_myMsgQueue.get_message()) != NULL) {
    if (pMsg->get_value() == MSG_SINK_FRAME) {
      uint32_t dontcare;
      CMediaFrame *mf = (CMediaFrame*)pMsg->get_message(dontcare);
      if (mf->RemoveReference()) {
	delete mf;
      }
    }
    delete pMsg;
  }

  if (m_audioResample != NULL) {
    for (uint ix = 0; ix < m_audioDstChannels; ix++) {
      st_resample_stop(m_audioResample[ix]);
      m_audioResample[ix] = NULL;
    }
    free(m_audioResample);
  }
  CHECK_AND_FREE(m_audioPreEncodingBuffer);
  debug_message("audio encoder thread %s exit", Profile()->GetName());
  return 0;
}
Beispiel #11
0
ismacryp_rc_t ismacrypGetKey (ismacryp_session_id_t session,
                              uint8_t key_num,
                              uint8_t *key_len,
                              uint8_t *salt_len,
                              uint8_t **key,
                              uint8_t **salt,
                              uint8_t *lifetime_exp)
{
 
  int i;
  ismacryp_session_t *sp;
  uint8_t *tempk, *temps;
  // only support one key for now so key_num is irrelevant
  if (findInSessionList(session, &sp)) {
    fprintf(stdout, "\nFailed to get key. Unknown session %d\n", session);
    return ismacryp_rc_sessid_error;
  }

  *key_len      = AES_KEY_LEN;
  *salt_len     = AES_SALT_LEN;
  *lifetime_exp = ISMACRYP_DEFAULT_KEY_LIFETIME_EXP;

  tempk = (uint8_t *) malloc((size_t) *key_len);
  temps = (uint8_t *) malloc((size_t) *salt_len);
   
  if ( tempk == NULL || temps == NULL ) {
     CHECK_AND_FREE(tempk);
     CHECK_AND_FREE(temps);
     fprintf(stdout, "\nFailed to get key mem error. Session %d\n", session);
     return ismacryp_rc_memory_error;
  }

  for (i=0; i<*key_len; i++ ) {
    tempk[i] = sp->kk.ksc.key[i];
  }
  *key = tempk;

  for (i=0; i<*salt_len; i++ ) {
    temps[i] = sp->kk.ksc.salt[i];
  }
  *salt = temps;

  return ismacryp_rc_ok;

}
CMpeg2tFile::~CMpeg2tFile (void)
{
  fclose(m_ifile);
  CHECK_AND_FREE(m_buffer);
  if (m_mpeg2t != NULL) 
    delete_mpeg2t_transport(m_mpeg2t);
  SDL_DestroyMutex(m_file_mutex);
  m_file_mutex = NULL;
}
Beispiel #13
0
void CXvidVideoEncoder::StopEncoder()
{
  CHECK_AND_FREE(m_vopBuffer);
  xvid_encore(m_xvidHandle, XVID_ENC_DESTROY, NULL, NULL);
  m_xvidHandle = NULL;
#ifdef WRITE_RAW
  fclose(m_raw_file);
#endif
}
void GenerateMpeg4VideoConfig(CVideoProfile *pConfig)
{
  CVideoEncoder *pVidEncoder = VideoEncoderCreate(pConfig, 
						  1460,
						  NULL, 
						  false);

  CHECK_AND_FREE(pConfig->m_videoMpeg4Config);
  if (pVidEncoder) {
    if (pVidEncoder->CanGetEsConfig()) {
      if (pVidEncoder->Init() == false) {
	error_message("Couldn't init encoder for VOL setting");
	delete pVidEncoder;
	return;
      }
      if (pVidEncoder->GetEsConfig(&pConfig->m_videoMpeg4Config,
				   &pConfig->m_videoMpeg4ConfigLength)) {
	delete pVidEncoder;
	return;
      }
    }
    delete pVidEncoder;
  }
  u_int8_t* pMpeg4Config = (u_int8_t*)Malloc(256);
	u_int32_t mpeg4ConfigLength = 0;

	MP4AV_Mpeg4CreateVosh(
		&pMpeg4Config,
		&mpeg4ConfigLength,
		// profile_level_id, default is 3, Simple Profile @ Level 3
		pConfig->m_videoMpeg4ProfileId);

	MP4AV_Mpeg4CreateVo(
		&pMpeg4Config,
		&mpeg4ConfigLength,
		1);

	uint vot = pConfig->GetBoolValue(CFG_VIDEO_USE_B_FRAMES) ?
	  17 : 1;
	MP4AV_Mpeg4CreateVol(
		&pMpeg4Config,
		&mpeg4ConfigLength,
		vot, 
		pConfig->GetFloatValue(CFG_VIDEO_FRAME_RATE),
		pConfig->GetIntegerValue(CFG_VIDEO_TIMEBITS) == 0, 
		// short time - true if we haven't set the # of bits
		true,	// variableRate
		pConfig->m_videoWidth,
		pConfig->m_videoHeight,
		0,	// quantType, H.263
		&pConfig->m_videoTimeIncrBits);

	free(pConfig->m_videoMpeg4Config);
	pConfig->m_videoMpeg4Config = pMpeg4Config;
	pConfig->m_videoMpeg4ConfigLength = mpeg4ConfigLength;
}
Beispiel #15
0
/*
 * free_rtsp_client()
 * frees all memory associated with rtsp client information
 */
void free_rtsp_client (rtsp_client_t *rptr)
{
  /*if (rptr->thread != NULL) {
    rtsp_close_thread(rptr);
  } else*/ {
    rtsp_close_socket(rptr);
#ifdef _WINDOWS
    WSACleanup();
#endif
  }

  CHECK_AND_FREE(rptr->orig_url);
  CHECK_AND_FREE(rptr->url);
  CHECK_AND_FREE(rptr->server_name);
  CHECK_AND_FREE(rptr->cookie);
  free_decode_response(rptr->decode_response);
  rptr->decode_response = NULL;
  free(rptr);
}
static void h264_rtp_destroy (rtp_plugin_data_t *pifptr)
{
  h264_rtp_data_t *iptr = (h264_rtp_data_t *)pifptr;

#ifdef ISMA_RTP_DUMP_OUTPUT_TO_FILE
  fclose(iptr->m_outfile);
#endif
  CHECK_AND_FREE(iptr->m_buffer);
  free(iptr);
}
static int insert_frame_data (isma_enc_rtp_data_t *iptr,
                              isma_frame_data_t *frame_data)
{
    SDL_LockMutex(iptr->m_rtp_packet_mutex);
    if (iptr->m_frame_data_head == NULL) {
        iptr->m_frame_data_head = frame_data;
    } else {
        int32_t diff;
        isma_frame_data_t *p, *q;
        q = NULL;
        p = iptr->m_frame_data_head;

        do {
            diff = frame_data->rtp_timestamp - p->rtp_timestamp;
            if (diff == 0) {
                isma_message(LOG_ERR, ismaencrtp, "Duplicate timestamp of %x found in RTP packet",
                             frame_data->rtp_timestamp);
                isma_message(LOG_DEBUG, ismaencrtp,
                             "Seq number orig %d new %d",
                             p->pak->rtp_pak_seq, frame_data->pak->rtp_pak_seq);
                // if fragmented frame, free all frag_data
                if (frame_data->is_fragment == 1) {
                    isma_frag_data_t * p = NULL;
                    while ((p = frame_data->frag_data) != NULL) {
                        frame_data->frag_data = p->frag_data_next;
                        CHECK_AND_FREE(p);
                    }
                }
                // put frame_data on free list
                frame_data->frame_data_next = iptr->m_frame_data_free;
                iptr->m_frame_data_free = frame_data;

                SDL_UnlockMutex(iptr->m_rtp_packet_mutex);
                return 1;
            } else if (diff < 0) {
                if (q == NULL) {
                    frame_data->frame_data_next = iptr->m_frame_data_head;
                    iptr->m_frame_data_head = frame_data;
                } else {
                    q->frame_data_next = frame_data;
                    frame_data->frame_data_next = p;
                }
                SDL_UnlockMutex(iptr->m_rtp_packet_mutex);
                return 0;
            }
            q = p;
            p = p->frame_data_next;
        } while (p != NULL);
        // insert at end;
        q->frame_data_next = frame_data;

    }
    SDL_UnlockMutex(iptr->m_rtp_packet_mutex);
    return 0;
}
static void isma_rtp_destroy (rtp_plugin_data_t *pifptr)
{
    isma_enc_rtp_data_t *iptr = (isma_enc_rtp_data_t *)pifptr;

#ifdef ISMA_RTP_DUMP_OUTPUT_TO_FILE
    fclose(iptr->m_outfile);
#endif
    isma_frame_data_t *p;

    if (iptr->m_frag_reass_buffer != NULL) {
        CHECK_AND_FREE(iptr->m_frag_reass_buffer);
        iptr->m_frag_reass_buffer = NULL;
    }
    if (iptr->m_frame_data_on != NULL) {
        iptr->m_frame_data_on->frame_data_next = iptr->m_frame_data_head;
        iptr->m_frame_data_head = iptr->m_frame_data_on;
        iptr->m_frame_data_on = NULL;
    }
    while (iptr->m_frame_data_free != NULL) {
        p = iptr->m_frame_data_free;
        iptr->m_frame_data_free = p->frame_data_next;
        CHECK_AND_FREE(p);
    }
    while (iptr->m_frame_data_head != NULL) {
        p = iptr->m_frame_data_head;
        // if fragmented frame, free all frag_data
        if (p->is_fragment == 1) {
            isma_frag_data_t * q = p->frag_data;
            while (q != NULL) {
                p->frag_data = q->frag_data_next;
                CHECK_AND_FREE(q);
                q = p->frag_data;
            }
        }
        iptr->m_frame_data_head = p->frame_data_next;
        CHECK_AND_FREE(p);
    }
    if (iptr->m_fmtp != NULL) {
        free_fmtp_parse(iptr->m_fmtp);
    }
    CHECK_AND_FREE(iptr);
}
CConfigList::~CConfigList (void)
{
  CConfigEntry *e;

  while (m_config_list != NULL) {
    e = m_config_list->GetNext();
    delete m_config_list;
    m_config_list = e;
  };
  CHECK_AND_FREE(m_directory);
}
Beispiel #20
0
void aac_close (codec_data_t *ptr)
{
  if (ptr == NULL) {
    return;
  }
  aac_codec_t *aac = (aac_codec_t *)ptr;
  faacDecClose(aac->m_info);
  aac->m_info = NULL;

  CHECK_AND_FREE(aac->m_temp_buff);
  CHECK_AND_FREE(aac->m_buffer);
  if (aac->m_ifile != NULL) {
    fclose(aac->m_ifile);
    aac->m_ifile = NULL;
  }
#if DUMP_OUTPUT_TO_FILE
  fclose(aac->m_outfile);
#endif
  free(aac);
}
Beispiel #21
0
static void ffmpeg_close (codec_data_t *ifptr)
{
    ffmpeg_codec_t *ffmpeg;

    ffmpeg = (ffmpeg_codec_t *)ifptr;
    if (ffmpeg->m_c != NULL) {
        avcodec_close(ffmpeg->m_c);
        free(ffmpeg->m_c);
    }
    CHECK_AND_FREE(ffmpeg->m_picture);
    free(ffmpeg);
}
Beispiel #22
0
void CX264VideoEncoder::StopEncoder (void)
{
#ifndef USE_OUR_YUV
  x264_picture_clean(&m_pic_input);
#endif
  x264_encoder_close(m_h);


  CHECK_AND_FREE(m_vopBuffer);
  CHECK_AND_FREE(m_YUV);
  CHECK_AND_FREE(m_nal_info);
#ifdef OUTPUT_RAW
  if (m_outfile) {
    fclose(m_outfile);
  }
#endif
  if (m_push != NULL) {
    delete m_push;
    m_push = NULL;
  }
	  
}
void CALSAAudioSource::DoStopCapture()
{
  if (!m_source) {
    return;
  }

  //  CMediaSource::DoStopAudio();

  snd_pcm_drop(m_pcmHandle);
  snd_pcm_close(m_pcmHandle);
  CHECK_AND_FREE(m_timestampOverflowArray);
  m_source = false;
}
bool CMp4EncAudioByteStream::start_next_frame (uint8_t **buffer, 
					       uint32_t *buflen,
					       frame_timestamp_t *pts,
					       void **ud)
{
  bool ret = CMp4AudioByteStream::start_next_frame(buffer, buflen, pts, ud);
  u_int8_t *temp_buffer = NULL;
  u_int32_t temp_this_frame_size = 0;
#ifdef ISMACRYP_DEBUG
  fwrite(*buffer, *buflen, 1, my_enc_file);
#endif
  ismacryp_rc_t ismacryprc;
  ismacryprc = ismacrypDecryptSampleRemoveHeader(m_ismaCryptSId, 
					*buflen,
					*buffer,
					&temp_this_frame_size,
					&temp_buffer);

  if ( ismacryprc != ismacryp_rc_ok ) {
    mp4f_message(LOG_ERR, "%s  1. decrypt error code:  %u" ,
	       m_name, ismacryprc);
    CHECK_AND_FREE(temp_buffer);
    // can't copy anything to buffer in this case.
    return ret; 
  }

#ifdef ISMACRYP_DEBUG
  fwrite(temp_buffer, temp_this_frame_size, 1, my_unenc_file);
#endif
  *buflen = temp_this_frame_size;
  memset(*buffer, 0, *buflen * sizeof(u_int8_t));
  memcpy(*buffer, temp_buffer, temp_this_frame_size);
#ifdef ISMACRYP_DEBUG
  fwrite(*buffer, *buflen, 1, my_unenc_file2);
#endif
  CHECK_AND_FREE(temp_buffer);
  return ret; 
}
Beispiel #25
0
bool CX264VideoEncoder::GetEncodedImage(
	u_int8_t** ppBuffer, u_int32_t* pBufferLength,
	Timestamp *dts, Timestamp *pts)
{
  if (m_vopBufferLength == 0) return false;

  h264_media_frame_t *mf = MALLOC_STRUCTURE(h264_media_frame_t);

  if (mf == NULL) {
    CHECK_AND_FREE(m_vopBuffer);
    m_vopBufferLength = 0;
    return false;
  }
  
  mf->buffer = m_vopBuffer;
  mf->buffer_len = m_vopBufferLength;
  mf->nal_number = m_nal_num;
  mf->nal_bufs = m_nal_info;
  m_nal_info = NULL;
  m_vopBuffer = NULL;
  *ppBuffer = (uint8_t *)mf;
  *pBufferLength = 0;

#if 1
  Timestamp pts_try = m_pic_output.i_pts + m_pts_add;
  Timestamp closest_on_stack = m_push->Closest(pts_try, m_frame_time);
  if (closest_on_stack != 0) {
    *pts = closest_on_stack;
  } else {
    *pts = pts_try;
  }
  //  debug_message("try "U64" closest "U64, pts_try, closest_on_stack);
#else 
  *pts = m_pic_output.i_pts + m_pts_add;
#endif
  *dts = m_push->Pop();
  //  debug_message("dts "U64" pts "U64" "D64" type %u ", *dts, *pts, *pts - *dts, m_pic_output.i_type);
  if (*dts > *pts) *pts = *dts;
  else if (*pts - *dts < 6) *pts = *dts;
#if 0
  if (*dts != *pts) {
    debug_message("PTS "U64" not DTS "U64, 
		  *pts, *dts);
  }
#endif
  m_vopBuffer = NULL;
  m_vopBufferLength = 0;
  
  return true;
}
Beispiel #26
0
  bool EncodeFrame (const char *fptr) {
    ADV_SPACE(fptr);
    CHECK_AND_FREE(m_encodedFrame);
    if (*fptr == 'A' || *fptr == '<') {
      // we have an already formatted href
      const char *check = fptr + 1;
      if (*check == '<') {
	check++;
      }
      if (strncmp(check, m_base_url, m_base_url_len) == 0) {
	check += m_base_url_len;
	m_encodedFrame = (char *)malloc(strlen(check) + 
					*fptr == 'A' ? 2 : 1);
	char *copyto = m_encodedFrame;
	if (*fptr == 'A') {
	  *copyto++ = 'A';
	}
	*copyto++ = '<';
	strcpy(copyto, check);
	debug_message("%s", m_encodedFrame);
      } else {
	m_encodedFrame = strdup(fptr);
      }
      chomp();
    } else {
      // we need to add <> and maybe an A
      uint32_t size = strlen(fptr) + 1; // add \0 at end
      if (strncmp(fptr, m_base_url, m_base_url_len) == 0) {
	fptr += m_base_url_len;
      }
      debug_message("string \"%s\"", fptr);
      size += 2; // add <>
      if (Profile()->GetBoolValue(CFG_TEXT_HREF_MAKE_AUTOMATIC)) size++;
      m_encodedFrame = (char *)malloc(size);
      char *write = m_encodedFrame;
      if (Profile()->GetBoolValue(CFG_TEXT_HREF_MAKE_AUTOMATIC)) {
	*write++ = 'A';
      }
      *write++ = '<';
      *write = '\0';
      strcat(write, fptr);
      debug_message("before chomp \"%s\"", m_encodedFrame);
      chomp();
      strcat(write, ">");
      debug_message("\"%s\"", m_encodedFrame);
    }
    m_encodedFrameLen = strlen(m_encodedFrame) + 1;
    return true;
  };
MCCacheWriter::~MCCacheWriter() {
#define CHECK_AND_FREE(VAR) if (VAR) { free(VAR); }

  CHECK_AND_FREE(mpHeaderSection);
  CHECK_AND_FREE(mpStringPoolSection);
  CHECK_AND_FREE(mpDependencyTableSection);
  CHECK_AND_FREE(mpPragmaListSection);
  CHECK_AND_FREE(mpObjectSlotSection);
  CHECK_AND_FREE(mpExportVarNameListSection);
  CHECK_AND_FREE(mpExportFuncNameListSection);

#undef CHECK_AND_FREE
}
// check where need to lock
static void cleanup_frag (isma_enc_rtp_data_t *iptr,
                          isma_frame_data_t * frame_data)
{
    // free all frag_data for this frame
    isma_frag_data_t * p = NULL;
    while ((p = frame_data->frag_data) != NULL) {
        frame_data->frag_data = p->frag_data_next;
        CHECK_AND_FREE(p);
    }
    // now put frame_data back on free list
    SDL_LockMutex(iptr->m_rtp_packet_mutex);
    frame_data->frame_data_next = iptr->m_frame_data_free;
    iptr->m_frame_data_free = frame_data;
    SDL_UnlockMutex(iptr->m_rtp_packet_mutex);
    return;
}
Beispiel #29
0
/*
 * Clean up - free everything
 */
CSDLVideo::~CSDLVideo (void)
{
  CHECK_AND_FREE(m_name);
  if (m_image) {
    SDL_FreeYUVOverlay(m_image);
    m_image = NULL;
  }
  if (m_screen) {
    SDL_FreeSurface(m_screen);
    m_screen = NULL;
  }
  if (m_mutex) {
    SDL_DestroyMutex(m_mutex);
    m_mutex = NULL;
  }
}
void CAudioEncoder::DoStopAudio()
{
  // flush remaining output from audio encoder
  // and forward it to sinks
  
  EncodeSamples(NULL, 0, m_audioSrcChannels);

  ForwardEncodedAudioFrames();

  StopEncoder();

  CHECK_AND_FREE(m_audioPreEncodingBuffer);
  debug_message("Audio profile %s stats", GetProfileName());
  debug_message(" encoded samples: "U64, m_audioDstSampleNumber);
  debug_message(" encoded frames: %u", m_audioDstFrameNumber);
}