Exemple #1
0
uint32_t  read_pty_slave(fs_node_t * node, uint32_t offset, uint32_t size, uint8_t *buffer) {
	pty_t * pty = (pty_t *)node->device;

	if (pty->tios.c_lflag & ICANON) {
		return ring_buffer_read(pty->in, size, buffer);
	} else {
		if (pty->tios.c_cc[VMIN] == 0) {
			return ring_buffer_read(pty->in, MIN(size, ring_buffer_unread(pty->in)), buffer);
		} else {
			return ring_buffer_read(pty->in, MIN(pty->tios.c_cc[VMIN], size), buffer);
		}
	}
}
Exemple #2
0
static int jack_process_callback(jack_nframes_t nframes, void *arg)
{
        struct state_jack_playback *s = (struct state_jack_playback *) arg;
        int i;
	int channels; // actual written channels (max of available and required)

	channels = s->desc.ch_count;
	if(channels > s->jack_ports_count)
		channels = s->jack_ports_count;

        for (i = 0; i < channels; ++i) {
                if(ring_get_current_size(s->data[i]) <= (int) (nframes * sizeof(float))) {
                        fprintf(stderr, "[JACK playback] Buffer underflow detected.\n");
                }
        }
        for (i = 0; i < channels; ++i) {
                int ret;
                jack_default_audio_sample_t *out =
                        jack_port_get_buffer (s->output_port[i], nframes);
                ret = ring_buffer_read(s->data[i], (char *)out, nframes * sizeof(float));
                if((unsigned int) ret != nframes * sizeof(float)) {
                        fprintf(stderr, "[JACK playback] Buffer underflow detected (channel %d).\n", i);
                }
        }

        return 0;
}
inline size_t
RingBuffer::Read(void* buffer, size_t length)
{
	if (fBuffer == NULL)
		return B_NO_MEMORY;

	return ring_buffer_read(fBuffer, (uint8*)buffer, length);
}
Exemple #4
0
static void _stp_ring_buffer_iterator_increment(struct _stp_iterator *iter)
{
	if (iter->buffer_iter[iter->cpu]) {
		_stp_ring_buffer_disable_cpu();
		ring_buffer_read(iter->buffer_iter[iter->cpu], NULL);
		_stp_ring_buffer_enable_cpu();
	}
}
Exemple #5
0
uint8_t usart_receive(uint8_t* data) {
  uint8_t buff;
  uint8_t i = 0;
  while(!ring_buffer_read(rx_buff, &buff)) {
    data[i++] = buff;
  }

  return i;
}
Exemple #6
0
static int display_deltacast_putf(void *state, struct video_frame *frame, int nonblock)
{
        struct state_deltacast *s = (struct state_deltacast *)state;
        struct timeval tv;
        int i;
        ULONG Result;

        UNUSED(frame);
        UNUSED(nonblock);

        assert(s->magic == DELTACAST_MAGIC);
        
        pthread_mutex_lock(&s->lock);
        if(s->play_audio && s->audio_configured) {
                /* Retrieve the number of needed samples */
                for(i = 0; i < s->audio_desc.ch_count; ++i) {
                        s->AudioInfo.pAudioGroups[i / 4].pAudioChannels[i % 4].DataSize = 0;
                }
                Result = VHD_SlotEmbedAudio(s->SlotHandle,&s->AudioInfo);
                if (Result != VHDERR_BUFFERTOOSMALL)
                {
                        fprintf(stderr, "[DELTACAST] ERROR : Cannot embed audio on TX0 stream. Result = 0x%08X\n",Result);
                } else {
                        for(i = 0; i < s->audio_desc.ch_count; ++i) {
                                int ret;
                                ret = ring_buffer_read(s->audio_channels[i], (char *) s->AudioInfo.pAudioGroups[i / 4].pAudioChannels[i % 4].pData, s->AudioInfo.pAudioGroups[i / 4].pAudioChannels[i % 4].DataSize);
                                if(!ret) {
                                        fprintf(stderr, "[DELTACAST] Buffer underflow for channel %d.\n", i);
                                }
                                s->AudioInfo.pAudioGroups[0].pAudioChannels[0].DataSize = ret;
                        }
                }
                /* Embed audio */
                Result = VHD_SlotEmbedAudio(s->SlotHandle,&s->AudioInfo);
                if (Result != VHDERR_NOERROR)
                {
                        fprintf(stderr, "[DELTACAST] ERROR : Cannot embed audio on TX0 stream. Result = 0x%08X\n",Result);
                }
        }
        pthread_mutex_unlock(&s->lock);

        VHD_UnlockSlotHandle(s->SlotHandle);
        s->SlotHandle = NULL;
        
        gettimeofday(&tv, NULL);
        double seconds = tv_diff(tv, s->tv);
        if (seconds > 5) {
                double fps = s->frames / seconds;
                log_msg(LOG_LEVEL_INFO, "[DELTACAST display] %lu frames in %g seconds = %g FPS\n",
                        s->frames, seconds, fps);
                s->tv = tv;
                s->frames = 0;
        }
        s->frames++;

        return 0;
}
static PyObject *
Buffer_read_piece(Buffer *self, PyObject *args, PyObject *kwargs)
{
    if ( ring_buffer_eof(self->buffer) ) {
        PyErr_SetString (InsufficientDataError, "No data in buffer");
        return NULL;
    }

    int bytes_available_for_read = ring_buffer_count_bytes (self->buffer);
    PyObject *datagram;
    if (bytes_available_for_read < self->buffer->page_size) {
        datagram = PyString_FromStringAndSize(NULL, bytes_available_for_read);
        ring_buffer_read (self->buffer, PyString_AsString(datagram), bytes_available_for_read);
    } else {
        datagram = PyString_FromStringAndSize(NULL, self->buffer->page_size);
        ring_buffer_read (self->buffer, PyString_AsString(datagram), bytes_available_for_read);
    }

    return datagram;
}
Exemple #8
0
struct audio_frame *audio_cap_jack_read(void *state)
{
        struct state_jack_capture *s = (struct state_jack_capture *) state;

        s->frame.data_len = ring_buffer_read(s->data, s->frame.data, s->frame.max_size);

        if(!s->frame.data_len)
                return NULL;

        return &s->frame;
}
Exemple #9
0
inline ssize_t
RingBuffer::Read(void* buffer, size_t length, bool isUser)
{
	if (fBuffer == NULL)
		return B_NO_MEMORY;
	if (isUser && !IS_USER_ADDRESS(buffer))
		return B_BAD_ADDRESS;

	return isUser
		? ring_buffer_user_read(fBuffer, (uint8*)buffer, length)
		: ring_buffer_read(fBuffer, (uint8*)buffer, length);
}
Exemple #10
0
static struct audio_frame *audio_cap_ca_read(void *state)
{
        struct state_ca_capture *s = (struct state_ca_capture *) state;
        int ret = FALSE;

        pthread_mutex_lock(&s->lock);
        ret = ring_buffer_read(s->buffer, s->frame.data, s->frame.max_size);
        if(!ret) {
                s->boss_waiting = TRUE;
                while(!s->data_ready) {
                        pthread_cond_wait(&s->cv, &s->lock);
                }
                s->boss_waiting = FALSE;
                ret = ring_buffer_read(s->buffer, s->frame.data, s->frame.max_size);
                s->data_ready = FALSE;
        }
        pthread_mutex_unlock(&s->lock);

        s->frame.data_len = ret;

        return &s->frame;
}
Exemple #11
0
static void sound_sdl_read(SoundDriver *driver, guint8 *stream, int len) {
	g_assert(driver != NULL);
	DriverData *data = (DriverData *)driver->driverData;

	if (!data->_initialized || len <= 0)
		return;

	SDL_LockMutex(data->_mutex);

	ring_buffer_read(data->_rbuf, stream, len);

	SDL_CondSignal(data->_cond);
	SDL_UnlockMutex(data->_mutex);
}
uint16_t ring_buffer_readline(ring_buffer* ring, char* buffer, uint16_t size) {
  uint8_t b;
  uint16_t i;
  for(i = 0; i < min(ring->available, size - 1); i++) {
    b = ring_buffer_peekn(ring, i);
    if(b == '\n') {
      i++;
      ring_buffer_read(ring, (uint8_t*)buffer, i);
      buffer[i] = '\0';
      return i;
    }
  }
  buffer[0] = '\0';
  return 0;
}
Exemple #13
0
static GIOStatus channel_read(GIOChannel *channel, gchar *buf, gsize count,
					gsize *bytes_read, GError **err)
{
	GAtMuxChannel *mux_channel = (GAtMuxChannel *) channel;
	unsigned int avail = ring_buffer_len_no_wrap(mux_channel->buffer);

	if (avail > count)
		avail = count;

	*bytes_read = ring_buffer_read(mux_channel->buffer, buf, avail);

	if (*bytes_read == 0)
		return G_IO_STATUS_AGAIN;

	return G_IO_STATUS_NORMAL;
}
Exemple #14
0
/**
 * send data to USB.
 */
void usb_send_data(void) {
    uint8_t txBuffer[VIRTUAL_COM_PORT_DATA_SIZE];
    uint16_t txCount;

    if (g_usb_deviceState != CONFIGURED) {
        return;
    }

    txCount = min(usb_tx_ring_buffer.available, VIRTUAL_COM_PORT_DATA_SIZE);
    if (txCount > 0) {
        ring_buffer_read(&usb_tx_ring_buffer, txBuffer, txCount);

        UserToPMABufferCopy(txBuffer, ENDP1_TXADDR, txCount);
        SetEPTxCount(ENDP1, txCount);
        SetEPTxValid(ENDP1);
    }
}
Exemple #15
0
static int read_data(void *opaque, uint8_t *buf, int buf_size)
{
	int ret = 0;
	RingBufferContext *ctx = (RingBufferContext*)opaque;
	int datsize = ring_buffer_datasize(ctx);
	int size = datsize;
	if(size <= 0)
		return 0;
	else if(size > buf_size)
		size = buf_size;
	//printf("avio read %p to %p, reqsize=%d, datsize=%d, rest=%d\n", opaque, buf, buf_size, datsize, datsize-buf_size);
	ret = ring_buffer_read(ctx, buf, size);
	if(ret == 0)
		ret = size;
	else
		ret = 0;
	return ret;
}
static PyObject *
Buffer_read(Buffer *self, PyObject *args, PyObject *kwargs)
{
    int count_bytes;
    char *kwlist[] = {"length", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &count_bytes))
        return NULL;

    int bytes_available_for_read = ring_buffer_count_bytes (self->buffer);
    if (bytes_available_for_read < count_bytes) {
        PyErr_SetString(InsufficientDataError, "Not enough data to read from");
        return NULL;
    }

    PyObject *datagram = PyString_FromStringAndSize(NULL, count_bytes);
    ring_buffer_read (self->buffer, PyString_AsString(datagram), count_bytes);
    return datagram;
}
u16 __mip_interface_parse_input_buffer(mip_interface *device_interface)
{
 u16 i, ret;
 mip_header          *header_ptr = (mip_header*)device_interface->mip_packet;
 parser_callback_ptr  callback_function = NULL;
 void                *callback_user_ptr = NULL;
 
 //Check that the parser is initialized
 if(device_interface->state != MIP_INTERFACE_INITIALIZED)
   return MIP_INTERFACE_ERROR;
 
  
 ///
 //Are we searching for a start condition? Requires: SYNC byte 1 & 2, and a valid header
 ///
 
 if(device_interface->mip_packet_byte_count < sizeof(mip_header)) 
 {
   
  ///
  //Get a start byte
  ///
   
  while((device_interface->mip_packet_byte_count == 0) && ring_buffer_count(&device_interface->input_buffer))
  {
    ret = ring_buffer_read(&device_interface->input_buffer, &device_interface->mip_packet[0], 1);
    
    //Found a potential start byte
    if((ret == RING_BUFFER_OK) && (device_interface->mip_packet[0] == MIP_SYNC_BYTE1))
    {
     device_interface->mip_packet_byte_count = 1;
     device_interface->parser_start_time     = mip_sdk_get_time_ms();
    }
  }
  
  ///
  //Get the rest of the header
  ///
  
  if(device_interface->mip_packet_byte_count > 0)
  {
   //Need at least the size of (header - start_byte) in the buffer to start processing
   if(ring_buffer_count(&device_interface->input_buffer) >= sizeof(mip_header) - 1)
   {
    //Try to get a header
    for(i=0; i < sizeof(mip_header) - 1; i++)
    {
     ring_buffer_lookahead_read(&device_interface->input_buffer, i, &device_interface->mip_packet[i+1], 1);
    }
     
    //If the header is valid, then continue to the next step
    if((header_ptr->sync2 == MIP_SYNC_BYTE2) && 
       (header_ptr->payload_size + MIP_HEADER_SIZE + MIP_CHECKSUM_SIZE <= MIP_MAX_PACKET_SIZE))
    {
     device_interface->mip_packet_byte_count = sizeof(mip_header);
    }
    else
    {
     //Header not found
     device_interface->parser_in_sync        = 0;
     device_interface->mip_packet_byte_count = 0;
     device_interface->parser_headers_skipped++;
    }
   }
   //Check for timeout on incoming packet
   else
   {
    //If a timeout happens, we probably had a badly-formed packet, start over
    if(__mip_interface_time_timeout(device_interface->parser_start_time, device_interface->packet_timeout) == MIP_INTERFACE_TIMEOUT)
    {
     device_interface->parser_timeouts++;
     
     //Reset the parser  
     device_interface->mip_packet_byte_count = 0;
     device_interface->parser_in_sync        = 0;
    }
   }
  }
 }

 
 ///
 //Header located, get the rest of the potential MIP packet
 ///
 
 if(device_interface->mip_packet_byte_count >= sizeof(mip_header))
 {
  //Wait for the rest of the packet to be available in the buffer
  if(ring_buffer_count(&device_interface->input_buffer) >= (sizeof(mip_header) - 1 + header_ptr->payload_size + MIP_CHECKSUM_SIZE))
  {
   //Get the remaining packet bytes
   for(i=0; i < header_ptr->payload_size + MIP_CHECKSUM_SIZE; i++)
   {
    ring_buffer_lookahead_read(&device_interface->input_buffer, sizeof(mip_header) - 1 + i, &device_interface->mip_packet[MIP_HEADER_SIZE + i], 1);
   }
     
   ///
   //Valid MIP Packet Found
   ///
   
   if(mip_is_checksum_valid(device_interface->mip_packet) == MIP_OK)
   {
    device_interface->mip_packet_byte_count += header_ptr->payload_size + MIP_CHECKSUM_SIZE;
    
    //Trigger the callback with the valid packet
    if(__mip_interface_find_callback(device_interface, header_ptr->descriptor_set, &callback_user_ptr, &callback_function) == MIP_INTERFACE_OK)
    {
     (*callback_function)(callback_user_ptr, device_interface->mip_packet, device_interface->mip_packet_byte_count, MIP_INTERFACE_CALLBACK_VALID_PACKET);
    }
   
    ring_buffer_consume_entries(&device_interface->input_buffer, device_interface->mip_packet_byte_count - 1);
     
    device_interface->parser_in_sync = 1;
 
    //Reset the parser  
    device_interface->mip_packet_byte_count = 0;
   } 

   ///
   //Inalid MIP Packet: Bad checksum
   ///
   
   else
   {
    //Trigger the callback with a bad checksum
    if(__mip_interface_find_callback(device_interface, header_ptr->descriptor_set, &callback_user_ptr, &callback_function) == MIP_INTERFACE_OK)
    {
     (*callback_function)(callback_user_ptr, device_interface->mip_packet, device_interface->mip_packet_byte_count, MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR);
    }
    
    if(device_interface->parser_in_sync)
    {
     device_interface->parser_num_bad_checksums++;   
    }
    
    device_interface->parser_in_sync = 0;     
   }
   
   //Reset the parser  
   device_interface->mip_packet_byte_count = 0;
  }
  //Check for timeout on incoming packet
  else
  {
   //If a timeout happens, we probably had a bad-form packet, start over
   if(__mip_interface_time_timeout(device_interface->parser_start_time, device_interface->packet_timeout) == MIP_INTERFACE_TIMEOUT)
   {
    //Trigger the callback with a timeout
    if(__mip_interface_find_callback(device_interface, header_ptr->descriptor_set, &callback_user_ptr, &callback_function) == MIP_INTERFACE_OK)
    {
     (*callback_function)(callback_user_ptr, device_interface->mip_packet, device_interface->mip_packet_byte_count, MIP_INTERFACE_CALLBACK_TIMEOUT);
    }

    device_interface->parser_timeouts++;
    device_interface->parser_in_sync = 0;

    //Reset the parser  
    device_interface->mip_packet_byte_count = 0;    
   }
  }
 }  
 
 return MIP_INTERFACE_OK;
}
Exemple #18
0
uint32_t keyboard_read(fs_node_t *node,
                       uint32_t offset,
                       uint32_t size,
                       uint8_t *buffer) {
  return ring_buffer_read(devfs_keyboard->buffer);
}
Exemple #19
0
int CFfmpeg::ReadData(int nNeed, unsigned char* pBuffer, int* pnRead)
{
	int buffer_read = 0;
	int ret;
	AVPacket pkt;

	pthread_mutex_lock(&iolock);
	if(!transcode)
	{
		ret = fread(pBuffer, 1, nNeed, m_pFp);
		if(ret<=0)
		{
			FFMPEG_ERROR("fread: %s", strerror(errno));
		}
		else
		{
			curpos += ret;
			buffer_read = ret;
		}
	}
	else
	{
		while(1)
		{
			ret = ring_buffer_datasize(&outputringbuffer);
			if(ret > 0)
			{
				int reqsize = nNeed - buffer_read;
				if(ret < reqsize)
					reqsize = ret;
				ret = ring_buffer_read(&outputringbuffer, pBuffer+buffer_read, reqsize);
				if(ret == 0)
				{
					buffer_read += reqsize;
				}
			}
			if(buffer_read >= nNeed)
				break;
			ret = av_read_frame(infmt_ctx, &pkt);
			if(ret == AVERROR_EOF)
			{
				FFMPEG_INFO("=== AVERROR_EOF");
				eof = 1;
				*pnRead = buffer_read;
				//pthread_mutex_lock(&iolock);
				curpos = avio_seek(infmt_ctx->pb, 0, SEEK_CUR);
				pthread_mutex_unlock(&iolock);
				return buffer_read;
			}
			else if(ret == AVERROR(EAGAIN))
			{
				continue;
			}
			else if(ret < 0)
			{
				FFMPEG_WARN("av_read_frame return %d", ret);
				*pnRead = buffer_read;
				//pthread_mutex_lock(&iolock);
				curpos = avio_seek(infmt_ctx->pb, 0, SEEK_CUR);
				pthread_mutex_unlock(&iolock);
				return buffer_read;
			}
			else if(ret >= 0)
			{
				AVStream *ost, *ist;
				AVFrame avframe;
				AVPacket opkt;
				int64_t pts_base;
				av_init_packet(&opkt);
				//opkt = pkt;
				if(pkt.stream_index == video)
				{
					ost = vst;
					ist = infmt_ctx->streams[video];
					opkt.stream_index = vst->index;
					pts_base = vdts_base;
					//printf("pts=%lld, dts=%lld, duration=%d\n", pkt.pts, pkt.dts, pkt.duration);
				}
				else if(pkt.stream_index == audio1)
				{
					ost = ast1;
					ist = infmt_ctx->streams[audio1];
					opkt.stream_index = ast1->index;
					pts_base = a1dts_base;

					if(acodec1)
					{
						uint8_t outbuffer[4096];
						int sample_size = sizeof(adecbuffer1);
						int frame_size = ost->codec->frame_size * 4;
						//FFMPEG_DEBUG("before decode, pts=0x%llx, dts=0x%llx", pkt.pts, pkt.dts);
						avcodec_decode_audio3(ist->codec, adecbuffer1, &sample_size, &pkt);
						//FFMPEG_DEBUG("after decode, pts=0x%llx, dts=0x%llx", pkt.pts, pkt.dts);
						ring_buffer_write(&adecrbuffer1, (uint8_t*)adecbuffer1, sample_size);
						while(ring_buffer_datasize(&adecrbuffer1) > frame_size)
						{
							av_init_packet(&opkt);
							ring_buffer_read(&adecrbuffer1, (uint8_t*)adecbuffer1, frame_size);
							ret = avcodec_encode_audio(ost->codec, outbuffer, sizeof(outbuffer), adecbuffer1);
							//printf("ret=%d\n", ret);
							opkt.data = outbuffer;
							opkt.size = ret;
							opkt.stream_index = ast1->index;
							if(pkt.pts != AV_NOPTS_VALUE)
								opkt.pts = av_rescale_q(pkt.pts, ist->time_base, ost->time_base)+pts_base;
							else
								opkt.pts = AV_NOPTS_VALUE;
							if (pkt.dts != AV_NOPTS_VALUE)
								opkt.dts = av_rescale_q(pkt.dts, ist->time_base, ost->time_base)+pts_base;
							else
								opkt.dts = av_rescale_q(pkt.dts, AV_TIME_BASE_Q, ost->time_base)+pts_base;
							opkt.duration = av_rescale_q(pkt.duration, ist->time_base, ost->time_base);
							opkt.flags |= AV_PKT_FLAG_KEY;
							//FFMPEG_DEBUG("audio1 rescaled, pts=0x%llx, dts=0x%llx", opkt.pts, opkt.dts);
							ret = av_interleaved_write_frame(oc, &opkt);
							if(ret != 0)
							{
								FFMPEG_ERROR("av_interleaved_write_frame ret %d", ret);
							}
							ost->codec->frame_number++;
							av_free_packet(&opkt);
						}
						av_free_packet(&pkt);
						continue;
					}
				}
				else if(pkt.stream_index == audio2)
				{
					ost = ast2;
					ist = infmt_ctx->streams[audio2];
					opkt.stream_index = ast2->index;
					pts_base = a2dts_base;

					if(acodec2)
					{
						uint8_t outbuffer[4096];
						int sample_size = sizeof(adecbuffer1);
						int frame_size = ost->codec->frame_size * 4;
						avcodec_decode_audio3(ist->codec, adecbuffer2, &sample_size, &pkt);
						ring_buffer_write(&adecrbuffer2, (uint8_t*)adecbuffer2, sample_size);
						while(ring_buffer_datasize(&adecrbuffer2) > frame_size)
						{
							av_init_packet(&opkt);
							ring_buffer_read(&adecrbuffer2, (uint8_t*)adecbuffer2, frame_size);
							ret = avcodec_encode_audio(ost->codec, outbuffer, sizeof(outbuffer), adecbuffer2);
							//printf("ret=%d\n", ret);
							opkt.data = outbuffer;
							opkt.size = ret;
							opkt.stream_index = ast2->index;
							if(pkt.pts != AV_NOPTS_VALUE)
								opkt.pts = av_rescale_q(pkt.pts, ist->time_base, ost->time_base)+pts_base;
							else
								opkt.pts = AV_NOPTS_VALUE;
							if (pkt.dts != AV_NOPTS_VALUE)
								opkt.dts = av_rescale_q(pkt.dts, ist->time_base, ost->time_base)+pts_base;
							else
								opkt.dts = av_rescale_q(pkt.dts, AV_TIME_BASE_Q, ost->time_base)+pts_base;
							opkt.duration = av_rescale_q(pkt.duration, ist->time_base, ost->time_base);
							opkt.flags |= AV_PKT_FLAG_KEY;
							ret = av_interleaved_write_frame(oc, &opkt);
							if(ret != 0)
							{
								FFMPEG_ERROR("av_interleaved_write_frame ret %d", ret);
							}
							ost->codec->frame_number++;
							av_free_packet(&opkt);
						}
						av_free_packet(&pkt);
						continue;
					}
				}
				else
				{
					av_free_packet(&pkt);
					continue;
				}

				avcodec_get_frame_defaults(&avframe);
				ost->codec->coded_frame = &avframe;
				avframe.key_frame = pkt.flags & AV_PKT_FLAG_KEY;
				if(pkt.pts != AV_NOPTS_VALUE)
					opkt.pts = av_rescale_q(pkt.pts, ist->time_base, ost->time_base)+pts_base;
				else
					opkt.pts = AV_NOPTS_VALUE;
				if (pkt.dts != AV_NOPTS_VALUE)
					opkt.dts = av_rescale_q(pkt.dts, ist->time_base, ost->time_base)+pts_base;
				else
					opkt.dts = av_rescale_q(pkt.dts, AV_TIME_BASE_Q, ost->time_base)+pts_base;
				opkt.duration = av_rescale_q(pkt.duration, ist->time_base, ost->time_base);
				opkt.data = pkt.data;
				opkt.size = pkt.size;
				if(bsfc && pkt.stream_index == video)
				{
					//printf("rescale pts=%lld, dts=%lld, duration=%d\n", opkt.pts, opkt.dts, opkt.duration);
					AVPacket new_pkt = opkt;
					int a = av_bitstream_filter_filter(bsfc, ost->codec, NULL, &new_pkt.data, &new_pkt.size, opkt.data, opkt.size, opkt.flags & AV_PKT_FLAG_KEY);
					if(a>0)
					{
						av_free_packet(&opkt);
						new_pkt.destruct = av_destruct_packet;
					}
					else if(a<0)
					{
						FFMPEG_ERROR("av_bitstream_filter_filter ret %d", a);
					}
					opkt = new_pkt;
				}
				ret = av_interleaved_write_frame(oc, &opkt);
				if(ret != 0)
				{
					FFMPEG_ERROR("av_interleaved_write_frame ret %d", ret);
				}
				ost->codec->frame_number++;
			}
			av_free_packet(&pkt);
		}
		curpos = avio_seek(infmt_ctx->pb, 0, SEEK_CUR);
	}
	*pnRead = buffer_read;
	pthread_mutex_unlock(&iolock);
	return buffer_read;
}
Exemple #20
0
ssize_t
RingBuffer::Read(void *buffer, size_t size)
{
	return ring_buffer_read(fBuffer, (uint8*)buffer, size);
}
Exemple #21
0
uint32_t  read_pty_master(fs_node_t * node, uint32_t offset, uint32_t size, uint8_t *buffer) {
	pty_t * pty = (pty_t *)node->device;

	/* Standard pipe read */
	return ring_buffer_read(pty->out, size, buffer);
}