static void play_file_av(int filefd, int vfd, int afd) { unsigned char buf[BUFFY]; int count; audioSetMute(afd, 1); videoBlank(vfd, 1); if (audio && !black) { audioStop(afd); deviceClear(afd, -1); audioSetAVSync(afd, 0); audioSelectSource(afd, AUDIO_SOURCE_MEMORY); audioPlay(afd); videoBlank(vfd, 0); } else if (audio && black) { deviceClear(afd, vfd); videoBlank(vfd, 1); audioSetAVSync(afd, 0); audioSelectSource(afd, AUDIO_SOURCE_MEMORY); videoSelectSource(vfd, VIDEO_SOURCE_MEMORY); audioPlay(afd); videoPlay(vfd); } else { deviceClear(afd, vfd); audioSetAVSync(afd, 1); audioSelectSource(afd, AUDIO_SOURCE_MEMORY); videoSelectSource(vfd, VIDEO_SOURCE_MEMORY); audioPlay(afd); videoPlay(vfd); videoBlank(vfd, 0); } if (dolby) { audioSetVolume(afd, 0); volset = 0; } else { audioSetVolume(afd, 255); volset = 1; } #ifndef __stub_posix_fadvise posix_fadvise(filefd, 0, 0, POSIX_FADV_SEQUENTIAL); #endif while ((count = read(filefd,buf,BUFFY)) > 0) scan_file_av(vfd,afd,buf,count); }
void load_iframe(int filefd, int fd) { struct stat st; struct video_still_picture sp; fstat(filefd, &st); sp.iFrame = (char *) malloc(st.st_size); sp.size = st.st_size; printf("I-frame size: %d\n", sp.size); if (!sp.iFrame) { printf("No memory for I-Frame\n"); return; } printf("read: %d bytes\n",read(filefd,sp.iFrame,sp.size)); videoStillPicture(fd,&sp); sleep(3); videoPlay(fd); }
static void copy_to_dvb(int vfd, int afd, int cfd, const uint8_t* ptr, const unsigned short len) { struct pollfd pfd[NFD]; unsigned short pos = 0; int stopped = 0; pfd[0].fd = STDIN_FILENO; pfd[0].events = POLLIN; pfd[1].fd = vfd; pfd[1].events = POLLOUT; pfd[2].fd = afd; pfd[2].events = POLLOUT; while (pos < len) { int ret; if ((ret = poll(pfd,NFD,1)) > 0) { if (pfd[1].revents & POLLOUT) { int cnt = write(cfd, ptr + pos, len - pos); if (cnt > 0) pos += cnt; else if (cnt < 0) { if (errno != EAGAIN && errno != EINTR) { perror("Write:"); exit(-1); } if (errno == EAGAIN) usleep(1000); continue; } } if (pfd[0].revents & POLLIN) { int c = getchar(); switch(c) { case 'z': if (audio && !black) { audioSetMute(afd, 1); } else { videoFreeze(vfd); } deviceClear(afd, -1); printf("playback frozen\n"); stopped = 1; break; case 's': if (audio) { audioStop(afd); deviceClear(afd, -1); } else { videoStop(vfd); deviceClear(afd, vfd); } printf("playback stopped\n"); stopped = 1; break; case 'c': if (audio && !black) { audioSetAVSync(afd, 0); deviceClear(afd, -1); audioSetMute(afd, 0); } else { audioSetAVSync(afd, 1); deviceClear(afd, vfd); videoContinue(vfd); } printf("playback continued\n"); stopped = 0; break; case 'p': if (audio) { deviceClear(afd, -1); audioSetAVSync(afd, 0); audioPlay(afd); } else { deviceClear(afd, vfd); audioSetAVSync(afd, 1); audioPlay(afd); videoPlay(vfd); } audioSetMute(afd, 0); printf("playback started\n"); stopped = 0; break; case 'f': audioSetAVSync(afd, 0); if (!audio) { audioSetMute(afd, 1); videoFastForward(vfd,0); } printf("fastforward\n"); stopped = 0; break; case 'm': audioSetAVSync(afd, 0); audioSetMute(afd, 1); printf("mute\n"); stopped = 0; break; case 'u': audioSetAVSync(afd, 1); audioSetMute(afd, 0); printf("unmute\n"); stopped = 0; break; case 'd': if (dolby) dolby = 0; else dolby++; break; case 'l': audioSetAVSync(afd, 0); if (!audio) { audioSetMute(afd, 1); videoSlowMotion(vfd,2); } printf("slowmotion\n"); stopped = 0; break; case 'q': videoContinue(vfd); exit(0); break; default: break; } } } else if (ret < 0) { if (errno != EAGAIN && errno != EINTR) { perror("Write:"); exit(-1); } if (errno == EAGAIN) usleep(1000); } } }
void play_file_video(int filefd, int fd) { char buf[BUFFY]; int count; int written; struct pollfd pfd[NFD]; // int stopped = 0; pfd[0].fd = STDIN_FILENO; pfd[0].events = POLLIN; pfd[1].fd = fd; pfd[1].events = POLLOUT; videoSelectSource(fd,VIDEO_SOURCE_MEMORY); videoPlay(fd); count = read(filefd,buf,BUFFY); write(fd,buf,count); while ( (count = read(filefd,buf,BUFFY)) >= 0 ){ written = 0; while(written < count){ if (poll(pfd,NFD,1)){ if (pfd[1].revents & POLLOUT){ written += write(fd,buf+written, count-written); } if (pfd[0].revents & POLLIN){ int c = getchar(); switch(c){ case 'z': videoFreeze(fd); printf("playback frozen\n"); // stopped = 1; break; case 's': videoStop(fd); printf("playback stopped\n"); // stopped = 1; break; case 'c': videoContinue(fd); printf("playback continued\n"); // stopped = 0; break; case 'p': videoPlay(fd); printf("playback started\n"); // stopped = 0; break; case 'f': videoFastForward(fd,0); printf("fastforward\n"); // stopped = 0; break; case 'm': videoSlowMotion(fd,2); printf("slowmotion\n"); // stopped = 0; break; case 'q': videoContinue(fd); exit(0); break; } } } } } }