Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Line # Hits Time Per Hit % Time Line Contents
- ==============================================================
- 1171 @profile
- 1172 def run_ni(self):
- 1173 1 7 7.0 0.0 capture = xbmc.RenderCapture()
- 1174 1 2 2.0 0.0 tw = capture.getHeight()
- 1175 1 2 2.0 0.0 th = capture.getWidth()
- 1176 1 2 2.0 0.0 tar = capture.getAspectRatio()
- 1177 1 1 1.0 0.0 width = self.infos[0]
- 1178 1 1 1.0 0.0 height = self.infos[1]
- 1179 1 1 1.0 0.0 ratio = self.infos[2]
- 1180 1 1 1.0 0.0 missed_capture_count = 0
- 1181 1 1 1.0 0.0 counter = 0
- 1182 1 1 1.0 0.0 length = width * height * 4
- 1183 1 1 1.0 0.0 sfps = self.infos[4]
- 1184 1 1 1.0 0.0 if sfps == 0:
- 1185 sfps = float(xbmc.getInfoLabel('System.FPS'))
- 1186 1 9 9.0 0.0 info('Initial video framerate reported as %s' % str(sfps))
- 1187 1 3 3.0 0.0 tpf = int(1000.0/sfps)
- 1188 1 2 2.0 0.0 sleeptime = int(0.1 * tpf)
- 1189 1 1 1.0 0.0 try:
- 1190 1 19 19.0 0.0 self.inDataMap = mmap.mmap(0, length + 11, 'AmbiBox_XBMC_SharedMemory', mmap.ACCESS_WRITE)
- 1191 1 1 1.0 0.0 if simul:
- 1192 1 3 3.0 0.0 self.inDataMap[0] = chr(248)
- 1193 except Exception, e:
- 1194 info('Error creating connection to Ambibox Windows')
- 1195 if hasattr(e, 'message'):
- 1196 info(str(e.message))
- 1197 return
- 1198 else:
- 1199 1 1 1.0 0.0 if self.inDataMap is None:
- 1200 info('Error creating connection to Ambibox Windows, no further information available')
- 1201 return
- 1202 1 33007 33007.0 0.4 capture.capture(width, height, xbmc.CAPTURE_FLAG_CONTINUOUS)
- 1203 1 3 3.0 0.0 if self.runtype == self.TYPE_STANDARD:
- 1204 self.playing_file = self.player.getPlayingFile()
- 1205 1272 5823 4.6 0.1 while self.exit_event(counter) is False:
- 1206 1271 3520392 2769.8 45.3 capture.waitForCaptureStateChangeEvent(tpf)
- 1207 1271 5661 4.5 0.1 cgcs = capture.getCaptureState()
- 1208 1271 2353 1.9 0.0 if cgcs == xbmc.CAPTURE_STATE_DONE:
- 1209 1271 3134 2.5 0.0 image = capture.getImage()
- 1210 1271 3690 2.9 0.0 self.inDataMap.seek(0)
- 1211 1271 2814 2.2 0.0 seeked = self.inDataMap.read_byte()
- 1212 1271 2406 1.9 0.0 if ord(seeked) == 248:
- 1213 1271 1929 1.5 0.0 if counter == 0:
- 1214 1 1 1.0 0.0 length = len(image)
- 1215 1 10 10.0 0.0 info('XBMCDirect Capture successful')XBMCDirect capture terminated
- 1216 1 4 4.0 0.0 notification(__language__(32034))
- 1217 # width
- 1218 1 2 2.0 0.0 self.inDataMap[1] = chr(width & 0xff)
- 1219 1 1 1.0 0.0 self.inDataMap[2] = chr((width >> 8) & 0xff)
- 1220 # height
- 1221 1 2 2.0 0.0 self.inDataMap[3] = (chr(height & 0xff))
- 1222 1 1 1.0 0.0 self.inDataMap[4] = (chr((height >> 8) & 0xff))
- 1223 # aspect ratio
- 1224 1 2 2.0 0.0 self.inDataMap[5] = (chr(int(ratio * 100)))
- 1225 # image format
- 1226 1 7 7.0 0.0 fmt = capture.getImageFormat()
- 1227 1 2 2.0 0.0 if fmt == 'RGBA':
- 1228 1 1 1.0 0.0 self.inDataMap[6] = (chr(0))
- 1229 elif fmt == 'BGRA':
- 1230 self.inDataMap[6] = (chr(1))
- 1231 else:
- 1232 self.inDataMap[6] = (chr(2))
- 1233 # datasize
- 1234 1 1 1.0 0.0 self.inDataMap[7] = (chr(length & 0xff))
- 1235 1 1 1.0 0.0 self.inDataMap[8] = (chr((length >> 8) & 0xff))
- 1236 1 2 2.0 0.0 self.inDataMap[9] = (chr((length >> 16) & 0xff))
- 1237 1 1 1.0 0.0 self.inDataMap[10] = (chr((length >> 24) & 0xff))
- 1238 1271 2899 2.3 0.0 a = str(image)
- 1239 1271 926552 729.0 11.9 self.inDataMap[11:(11+length)] = str(a)
- 1240 # write first byte to indicate we finished writing the data
- 1241 1271 4109 3.2 0.1 self.inDataMap[0] = (chr(240))
- 1242 1271 1999 1.6 0.0 counter += 1
- 1243 1271 3248890 2556.2 41.8 xbmc.sleep(sleeptime)
- 1244 1271 6305 5.0 0.1 if simul: self.inDataMap[0] = chr(248)
- 1245 elif cgcs == xbmc.CAPTURE_STATE_WORKING:
- 1246 missed_capture_count += 1
- 1247 continue
- 1248 elif cgcs == xbmc.CAPTURE_STATE_FAILED:
- 1249 info('XBMCDirect Capture stopped after %s frames' % counter)
- 1250 if (self.runtype == XBMCD.TYPE_THREADED and self.killswitch is False) or self.runtype == XBMCD.TYPE_STANDARD:
- 1251 notification(__language__(32035)) # @[XBMCDirect Fail]
- 1252 break
- 1253 del capture
- 1254 info('XBMCDirect capture terminated')
- 1255 if missed_capture_count != 0:
- 1256 info('XBMCDirect reports missing %s captures due to RenderCapture timeouts' % missed_capture_count)
- 1257 self.inDataMap.close()
- 1258 self.inDataMap = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement