1 /***************************************************************************
2
3 Handle preview mode
4
5 It is displayed in 3 layers
6
7
8 Engine : Call setPreviewMode and amdPreview depending on the actions
9 previewMode is the **current** preview mode
10
11 admPreview :
12 Allocate/desallocate ressources
13 Build preview window
14 Call display properly to display it
15
16 GUI_PreviewXXXX
17 UI toolkit to actually display the window
18 See GUI_ui.h to see them
19
20
21
22 copyright : (C) 2007 by mean
23 email : fixounet@free.fr
24 ***************************************************************************/
25
26 /***************************************************************************
27 * *
28 * This program is free software; you can redistribute it and/or modify *
29 * it under the terms of the GNU General Public License as published by *
30 * the Free Software Foundation; either version 2 of the License, or *
31 * (at your option) any later version. *
32 * *
33 ***************************************************************************/
34 #include "ADM_cpp.h"
35 #include "config.h"
36
37 #include "ADM_default.h"
38 #include "ADM_edit.hxx"
39 #include "ADM_render/GUI_render.h"
40
41 #include "ADM_commonUI/GUI_ui.h"
42 #include "ADM_preview.h"
43
44 #include "DIA_coreToolkit.h"
45
46 #define MAX(a,b) ( (a)>(b) ? (a) : (b) )
47
48 /*************************************/
49 /*************************************/
50 extern ADM_Composer *video_body;
51 /**
52 \fn getCurrentPts
53 \brief returns the PTS in us of the last displayed frame
54 */
getCurrentPts(void)55 uint64_t admPreview::getCurrentPts(void)
56 {
57 if(rdrImage) return rdrImage->Pts;
58 return 0LL;
59 }
60 /**
61 \fn admPreview::seekToTime
62 \brief Seek to any given frame
63
64 @param timeframe Time of the image
65 */
66
seekToTime(uint64_t timeframe)67 bool admPreview::seekToTime(uint64_t timeframe)
68 {
69 if(!video_body->goToTimeVideo(timeframe))
70 {
71 ADM_warning(" seeking for frame at %" PRIu64" ms failed\n",timeframe/1000LL);
72 return false;
73 }
74 return samePicture();
75 }
76 /**
77 \fn admPreview::seekToIntraPts
78 \brief Seek to intra at PTS given as arg
79
80 @param timeframe Time of the image
81 */
82
seekToIntraPts(uint64_t timeframe)83 bool admPreview::seekToIntraPts(uint64_t timeframe)
84 {
85 uint64_t pts=getCurrentPts();
86 if(timeframe==pts)
87 return true;
88 if(!video_body->goToIntraTimeVideo(timeframe))
89 {
90 ADM_warning(" seeking for frame at %" PRIu64" ms failed\n",timeframe/1000LL);
91 return false;
92 }
93 return samePicture();
94 }
95 /**
96 \fn samePicture
97 */
samePicture(void)98 uint8_t admPreview::samePicture(void)
99 {
100 if(!video_body->samePicture(rdrImage)) return false;
101 return updateImage();
102 }
103 /**
104 \fn admPreview::update
105 \brief display data associated with framenum image
106 @param image : current main image (input)
107 @param framenum, framenumber
108 */
109
nextPicture(void)110 uint8_t admPreview::nextPicture(void)
111 {
112
113 if(!video_body->nextPicture(rdrImage)) return 0;
114 return updateImage();
115 }
116
117 /**
118 \fn admPreview::update
119 \brief display data associated with framenum image
120 @param image : current main image (input)
121 @param framenum, framenumber
122 */
123
previousPicture(void)124 uint8_t admPreview::previousPicture(void)
125 {
126 if(!video_body->previousPicture(rdrImage)) return 0;
127 return updateImage();
128 }
129 /**
130 \fn nextKeyFrame
131
132 */
nextKeyFrame(void)133 bool admPreview::nextKeyFrame(void)
134 {
135 uint64_t pts=getCurrentPts();
136 ADM_info("Current PTS :%" PRId64" ms\n",pts/1000LL);
137 if(false==video_body->getNKFramePTS(&pts))
138 {
139 ADM_warning("Cannot find next keyframe\n");
140 return false;
141 }
142 ADM_info("next kf PTS :%" PRId64" ms\n",pts/1000LL);
143 return seekToIntraPts(pts);
144 }
145 /**
146 \fn previousKeyFrame
147
148 */
previousKeyFrame(void)149 bool admPreview::previousKeyFrame(void)
150 {
151 uint64_t pts=getCurrentPts();
152 ADM_info("Current PTS :%" PRId64" ms\n",pts/1000LL);
153 if(false==video_body->getPKFramePTS(&pts))
154 {
155 ADM_warning("Cannot find previous keyframe\n");
156 return false;
157 }
158 ADM_info("next kf PTS :%" PRId64" ms\n",pts/1000LL);
159 return seekToIntraPts(pts);
160 }
161 // EOF
162