/* release and undisplay all saved regions */ void releaseRegions() { region_t* next, *old; Writer_t* writer; if (firstRegion == NULL) return; writer = getDefaultFramebufferWriter(); if (writer == NULL) { ass_err("no framebuffer writer found!\n"); } next = firstRegion; while (next != NULL) { if (writer) { WriterFBCallData_t out; ass_printf(100, "release: w %d h %d x %d y %d\n", next->w, next->h, next->x, next->y); out.fd = framebufferFD; out.data = NULL; out.Width = next->w; out.Height = next->h; out.x = next->x; out.y = next->y; out.Screen_Width = screen_width; out.Screen_Height = screen_height; out.destination = destination; out.destStride = destStride; writer->writeData(&out); if(threeDMode == 1){ out.x = screen_width/2 + next->x; writer->writeData(&out); }else if(threeDMode == 2){ out.y = screen_height/2 + next->y; writer->writeData(&out); } } old = next; next = next->next; free(old); } firstRegion = NULL; }
static int reset(Context_t *context) { int ret = cERR_LINUXDVB_NO_ERROR; Writer_t* writer = NULL; char * Encoding = NULL; context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); writer = getWriter(Encoding); if (writer == NULL) { linuxdvb_err("unknown video codec %s\n",Encoding); ret = cERR_LINUXDVB_ERROR; } else { writer->reset(); } free(Encoding); context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding); writer = getWriter(Encoding); if (writer == NULL) { linuxdvb_err("unknown audio codec %s\n",Encoding); ret = cERR_LINUXDVB_ERROR; } else { writer->reset(); } free(Encoding); return ret; }
/* check for regions which should be undisplayed. * we are very tolerant on time here, because * regions are also released when new regions are * detected (see ETSI EN 300 743 Chapter Page Composition) */ void checkRegions() { #define cDeltaTime 2 region_t* next, *old, *prev; Writer_t* writer; time_t now = time(NULL); if (firstRegion == NULL) return; writer = getDefaultFramebufferWriter(); if (writer == NULL) { ass_err("no framebuffer writer found!\n"); } prev = next = firstRegion; while (next != NULL) { if (now > next->undisplay + cDeltaTime) { ass_printf(100, "undisplay: %ld > %ld\n", now, next->undisplay + cDeltaTime); if (writer) { WriterFBCallData_t out; ass_printf(100, "release: w %d h %d x %d y %d\n", next->w, next->h, next->x, next->y); out.fd = framebufferFD; out.data = NULL; out.Width = next->w; out.Height = next->h; out.x = next->x; out.y = next->y; out.Screen_Width = screen_width; out.Screen_Height = screen_height; out.destination = destination; out.destStride = destStride; writer->writeData(&out); if(threeDMode == 1){ out.x = screen_width/2 + next->x; writer->writeData(&out); }else if(threeDMode == 2){ out.y = screen_height/2 + next->y; writer->writeData(&out); } } old = next; next = prev->next = next->next; if (old == firstRegion) firstRegion = next; free(old); } else { prev = next; next = next->next; } } }
// Write to decoder static int Write(void *_context, void* _out) { Context_t *context = (Context_t *) _context; AudioVideoOut_t *out = (AudioVideoOut_t*) _out; int ret = cERR_LINUXDVB_NO_ERROR; int res = 0; unsigned char video = 0; unsigned char audio = 0; Writer_t * writer = NULL; WriterAVCallData_t call; if (out == NULL) { linuxdvb_err("null pointer passed\n"); return cERR_LINUXDVB_ERROR; } video = !strcmp("video", out->type); audio = !strcmp("audio", out->type); linuxdvb_printf(20, "DataLength=%u PrivateLength=%u Pts=%llu FrameRate=%f\n", out->len, out->extralen, out->pts, out->frameRate); linuxdvb_printf(20, "v%d a%d\n", video, audio); if (video) { char * Encoding = NULL; context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); linuxdvb_printf(20, "Encoding = %s\n", Encoding); writer = getWriter(Encoding); if (writer == NULL) { linuxdvb_printf(20, "searching default writer ... %s\n", Encoding); writer = getDefaultVideoWriter(); } if (writer == NULL) { linuxdvb_err("unknown video codec and no default writer %s\n",Encoding); ret = cERR_LINUXDVB_ERROR; } else { call.fd = videofd; call.data = out->data; call.len = out->len; call.Pts = out->pts; call.private_data = out->extradata; call.private_size = out->extralen; call.FrameRate = out->frameRate; call.FrameScale = out->timeScale; call.Width = out->width; call.Height = out->height; call.Version = 0; // is unsingned char if (writer->writeData) res = writer->writeData(&call); if (res <= 0) { linuxdvb_err("failed to write data %d - %d\n", res, errno); linuxdvb_err("%s\n", strerror(errno)); ret = cERR_LINUXDVB_ERROR; } } free(Encoding); } else if (audio) { char * Encoding = NULL; context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding); linuxdvb_printf(20, "%s::%s Encoding = %s\n", FILENAME, __FUNCTION__, Encoding); writer = getWriter(Encoding); if (writer == NULL) { linuxdvb_printf(20, "searching default writer ... %s\n", Encoding); writer = getDefaultAudioWriter(); } if (writer == NULL) { linuxdvb_err("unknown audio codec %s and no default writer\n",Encoding); ret = cERR_LINUXDVB_ERROR; } else { call.fd = audiofd; call.data = out->data; call.len = out->len; call.Pts = out->pts; call.private_data = out->extradata; call.private_size = out->extralen; call.FrameRate = out->frameRate; call.FrameScale = out->timeScale; call.Version = 0; /* -1; unsigned char cannot be negative */ if (writer->writeData) res = writer->writeData(&call); if (res <= 0) { linuxdvb_err("failed to write data %d - %d\n", res, errno); linuxdvb_err("%s\n", strerror(errno)); ret = cERR_LINUXDVB_ERROR; } } free(Encoding); } return ret; }