SCM ffmpeg_decode_audio_video(SCM scm_self) { SCM retval = SCM_BOOL_F; struct ffmpeg_t *self = get_self(scm_self); if (!is_input_context(self)) scm_misc_error("ffmpeg-decode-audio/video", "Attempt to read frame from FFmpeg output video", SCM_EOL); while (scm_is_false(retval)) { if (packet_empty(self)) read_packet(self); int reading_cache = packet_empty(self); if (self->pkt.stream_index == self->audio_stream_idx) { av_frame_unref(self->audio_target_frame); retval = decode_audio(self, &self->pkt, self->audio_target_frame); } else if (self->pkt.stream_index == self->video_stream_idx) { av_frame_unref(self->video_target_frame); retval = decode_video(self, &self->pkt, self->video_target_frame); } else consume_packet_data(&self->pkt, self->pkt.size); if (scm_is_false(retval) && reading_cache) break; }; return retval; }
/* JDD's code */ void debug_out(struct buffer& b) { for (size_t i=0; i<b.num_samples; i++) { struct sample& c = b.samples[i]; ProcessInfo& pi = getProcessInfo(c.pid, packet_empty()); fprintf(stderr, "%lu,%u,%lu,%u,%u,%u,%u,%u,%u,%s,%s\n", c.pid, b.core, c.cycles, c.counters[0], c.counters[1], c.counters[2], c.counters[3], c.counters[4], c.counters[5], pi.cmdline.c_str(), pi.executable.c_str()); } }
int network_send(struct buffer &b, uint32_t missed, size_t *total) { size_t sent = 0; size_t sent_total = 0; size_t index = 0; void *data = NULL; assert(b.num_samples <= BUFFER_ENTRIES); if (debug) fprintf(stderr, "STARTING BATCH WITH %u SAMPLES!\n", b.num_samples); packet_start_batch(); for (index = 0; index < b.num_samples; ++index) { struct sample &s = b.samples[index]; struct ProcessInfo& pi = getProcessInfo(s.pid, packet_empty()); if (packet_should_create(b, s, pi)) { if (debug) fprintf(stderr, "PACKET MUST BE SENT BEFORE CONTINUING.\n"); if (transmit(&sent)) return -1; sent_total += sent; } /* This should never happen given the above statement */ if (packet_append(b, s, pi, missed)) return -1; } /* Anything at the end should be sent */ if (transmit(&sent)) return -1; sent_total += sent; if (total) *total = sent_total; return 0; }