1 | #ifndef SHOWIFRAME_H
|
---|
2 | #define SHOWIFRAME_H
|
---|
3 |
|
---|
4 | //flag 0: stop service
|
---|
5 | //flag 1: not stop service
|
---|
6 | int singlepicstart(const char *filename, int flag)
|
---|
7 | {
|
---|
8 | int ret = 0;
|
---|
9 |
|
---|
10 | if(status.aktservice->type != STILLPIC)
|
---|
11 | {
|
---|
12 | if(flag == 0)
|
---|
13 | {
|
---|
14 | ret = servicestop(status.aktservice, 0, 1);
|
---|
15 | if(ret == 1) return 1;
|
---|
16 | }
|
---|
17 | }
|
---|
18 |
|
---|
19 | int fd = open(filename, O_RDONLY);
|
---|
20 | if(fd >= 0)
|
---|
21 | {
|
---|
22 | struct dvbdev* videonode = NULL;
|
---|
23 | struct stat s;
|
---|
24 | fstat(fd, &s);
|
---|
25 |
|
---|
26 | if(status.aktservice->type != STILLPIC)
|
---|
27 | {
|
---|
28 | if(status.aktservice->videodev != NULL)
|
---|
29 | {
|
---|
30 | videoclose(status.aktservice->videodev, -1);
|
---|
31 | status.aktservice->videodev = NULL;
|
---|
32 | }
|
---|
33 | videonode = videoopen(0, 0);
|
---|
34 | videoselectsource(videonode, VIDEO_SOURCE_MEMORY);
|
---|
35 |
|
---|
36 | videosetformat(videonode, VIDEO_FORMAT_16_9);
|
---|
37 | videosetstreamtype(videonode, MPEGV);
|
---|
38 | videoplay(videonode);
|
---|
39 | }
|
---|
40 | else
|
---|
41 | videonode = status.aktservice->videodev;
|
---|
42 |
|
---|
43 | if(videonode != NULL)
|
---|
44 | {
|
---|
45 | struct video_still_picture stillpic;
|
---|
46 | char* iframe = NULL;
|
---|
47 |
|
---|
48 | iframe = malloc(s.st_size);
|
---|
49 | if(iframe == NULL)
|
---|
50 | {
|
---|
51 | err("no mem");
|
---|
52 | close(fd);
|
---|
53 | return 1;
|
---|
54 | }
|
---|
55 |
|
---|
56 | status.aktservice->type = STILLPIC;
|
---|
57 | status.aktservice->videodev = videonode;
|
---|
58 |
|
---|
59 | TEMP_FAILURE_RETRY(read(fd, iframe, s.st_size));
|
---|
60 | stillpic.iFrame = iframe;
|
---|
61 | stillpic.size = s.st_size;
|
---|
62 |
|
---|
63 | #ifdef MIPSEL
|
---|
64 | int seq_end_avail = 0;
|
---|
65 | size_t pos = 0;
|
---|
66 | unsigned char pes_header[] = {0x0, 0x0, 0x1, 0xe0, 0x00, 0x00, 0x80, 0x80, 0x5, 0x21, 0x0, 0x1, 0x0, 0x1};
|
---|
67 | unsigned char seq_end[] = {0x00, 0x00, 0x01, 0xB7};
|
---|
68 | unsigned char stuffing[8192];
|
---|
69 |
|
---|
70 | memset(stuffing, 0, 8192);
|
---|
71 |
|
---|
72 | while(pos <= (s.st_size - 4) && !(seq_end_avail = (!iframe[pos] && !iframe[pos + 1] && iframe[pos + 2] == 1 && iframe[pos + 3] == 0xB7)))
|
---|
73 | ++pos;
|
---|
74 |
|
---|
75 | if((iframe[3] >> 4) != 0xE) // no pes header
|
---|
76 | write(videonode->fd, pes_header, sizeof(pes_header));
|
---|
77 | else
|
---|
78 | iframe[4] = iframe[5] = 0x00;
|
---|
79 |
|
---|
80 | write(videonode->fd, iframe, s.st_size);
|
---|
81 |
|
---|
82 | if(!seq_end_avail)
|
---|
83 | write(videonode->fd, seq_end, sizeof(seq_end));
|
---|
84 |
|
---|
85 | write(videonode->fd, stuffing, 8192);
|
---|
86 | #else
|
---|
87 | videoclearbuffer(videonode);
|
---|
88 | videostillpicture(videonode, &stillpic);
|
---|
89 | #endif
|
---|
90 |
|
---|
91 | free(iframe); iframe = NULL;
|
---|
92 | }
|
---|
93 | close(fd);
|
---|
94 | }
|
---|
95 | else
|
---|
96 | {
|
---|
97 | err("open %s\n", filename);
|
---|
98 | return 1;
|
---|
99 | }
|
---|
100 | return 0;
|
---|
101 | }
|
---|
102 |
|
---|
103 | #endif
|
---|