source: titan/titan/showiframe.h @ 15272

Last change on this file since 15272 was 13883, checked in by nit, 12 years ago

fix

File size: 1.4 KB
Line 
1#ifndef SHOWIFRAME_H
2#define SHOWIFRAME_H
3
4//flag 0: stop service
5//flag 1: not stop service
6int singlepicstart(const char *filename, int flag)
7{
8        debug(1000, "in -> %s", filename);
9        int ret = 0;
10
11        if(status.aktservice->type != STILLPIC)
12        {
13                if(flag == 0)
14                {
15                        ret = servicestop(status.aktservice, 0, 1);
16                        if(ret == 1) return 1;
17                }
18        }
19
20        int fd = open(filename, O_RDONLY);
21        if(fd >= 0)
22        {
23                struct dvbdev* videonode = NULL;
24                struct stat s;
25                fstat(fd, &s);
26
27                if(status.aktservice->type != STILLPIC)
28                {
29                        videonode = videoopen(0);
30                        videoselectsource(videonode, VIDEO_SOURCE_MEMORY);
31
32                        videosetformat(videonode, VIDEO_FORMAT_16_9);
33                        videosetstreamtype(videonode, MPEGV);
34                        videoplay(videonode);
35                }       
36                else
37                        videonode = status.aktservice->videodev;
38
39                if(videonode != NULL)
40                {
41                        struct video_still_picture stillpic;
42                        char* iframe = NULL;
43
44                        iframe = malloc(s.st_size);
45                        if(iframe == NULL)
46                        {
47                                err("no mem");
48                                close(fd);
49                                return 1;
50                        }
51
52                        status.aktservice->type = STILLPIC;
53                        status.aktservice->videodev = videonode;
54
55                        TEMP_FAILURE_RETRY(read(fd, iframe, s.st_size));
56                        stillpic.iFrame = iframe;
57                        stillpic.size = s.st_size;
58
59                        videoclearbuffer(videonode);
60                        videostillpicture(videonode, &stillpic);
61
62                        free(iframe); iframe = NULL;
63                }
64                close(fd);
65        }
66        else
67        {
68                err("open %s\n", filename);
69                return 1;
70        }
71        debug(1000, "out");
72        return 0;
73}
74
75#endif
Note: See TracBrowser for help on using the repository browser.