Skip to content

Commit 42262a9

Browse files
author
stevevista
committed
no need to inject loadfile.c
1 parent 592642d commit 42262a9

File tree

15 files changed

+16765
-3712
lines changed

15 files changed

+16765
-3712
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ README.pdf
2121
.third-party
2222
*.lib
2323
ipc_channels.prod.json
24+
*.weights

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ UNZIP PREBUILT LIBRARIES TO <SRC>/.third-party/prebuilt
6565

6666
COPY OPENGL HEADERS TO <SRC>/.third-party/prebuilt/include
6767

68+
Download yolov4-tiny.weights and put it in electron-mpv root directory
69+
70+
6871

6972
## YOLOv4:
7073
* **source code:** https://github.com/AlexeyAB/darknet

package-lock.json

+15,654
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nacl-mpv-plugin/CMakeLists.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ set(MPV_BASIC_SOURCES
245245
src/mpv/sub/ass_mp.c
246246
src/mpv/sub/osd.c
247247
src/mpv/sub/osd_libass.c
248-
src/mpv/sub/sd_ass.c
249248
src/mpv/sub/dec_sub.c
250249
src/mpv/sub/img_convert.c
251250
src/mpv/sub/sd_lavc.c
@@ -315,6 +314,7 @@ set(MPV_BASIC_SOURCES
315314
src/mpv/video/out/gpu/libmpv_gpu.c
316315
src/mpv/video/out/opengl/libmpv_gl.c
317316
src/mpv/video/out/opengl/context.c
317+
src/mpv/player/loadfile.c
318318
src/mpv/player/audio.c
319319
src/mpv/player/video.c
320320
src/mpv/player/client.c
@@ -328,12 +328,9 @@ set(MPV_BASIC_SOURCES
328328
src/mpv/player/configfiles.c
329329
src/mpv/player/external_files.c
330330
src/mpv/player/scripting.c
331-
src/sd_ass_ai.c
331+
src/mpv-patched/sub/sd_ass.c
332332
src/mpv-patched/stream/stream_lavf.c
333-
src/mpv-patched/filters/f_decoder_wrapper.c
334-
src/mpv-patched/player/loadfile.c)
335-
336-
set_source_files_properties(src/mpv/sub/sd_ass.c PROPERTIES COMPILE_FLAGS /Dsd_ass=orgin_sd_ass)
333+
src/mpv-patched/filters/f_decoder_wrapper.c)
337334

338335
add_library(mpv_common_objs OBJECT ${MPV_BASIC_SOURCES})
339336
mpv_compile_definitions(mpv_common_objs)
@@ -367,6 +364,8 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR
367364
execute_process(COMMAND python "${MPV_SRC_PATH}/TOOLS/file2string.py" "${MPV_SRC_PATH}/etc/builtin.conf" OUTPUT_FILE "${PROJECT_BINARY_DIR}/generated/etc/builtin.conf.inc")
368365
execute_process(COMMAND python "${MPV_SRC_PATH}/TOOLS/file2string.py" "${MPV_SRC_PATH}/etc/input.conf" OUTPUT_FILE "${PROJECT_BINARY_DIR}/generated/etc/input.conf.inc")
369366
execute_process(COMMAND python "${MPV_SRC_PATH}/TOOLS/file2string.py" "${MPV_SRC_PATH}/sub/osd_font.otf" OUTPUT_FILE "${PROJECT_BINARY_DIR}/generated/sub/osd_font.otf.inc")
367+
execute_process(COMMAND python "${MPV_SRC_PATH}/TOOLS/matroska.py" "--generate-header" OUTPUT_FILE "${PROJECT_BINARY_DIR}/generated/ebml_types.h")
368+
execute_process(COMMAND python "${MPV_SRC_PATH}/TOOLS/matroska.py" "--generate-definitions" OUTPUT_FILE "${PROJECT_BINARY_DIR}/generated/ebml_defs_REAL.c")
370369

371370
add_library(mpv-core SHARED
372371
$<TARGET_OBJECTS:mpv_common_objs>

src/nacl-mpv-plugin/player-components.js

+24-61
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// nameing with postfix 'Plugin', to workaround test script without window.require
22
const PlayerPlugin = require('./player')
3-
const { mime } = require('./index')
3+
const { mime: mimePlayer } = require('./index')
44

55
function attrTrue (val) {
66
return val === '' ||
@@ -12,9 +12,7 @@ class BasePlayerElement extends HTMLElement {
1212
super()
1313

1414
const shadowRoot = this.attachShadow({mode: 'closed'});
15-
shadowRoot.innerHTML = `
16-
<embed id="player" type="${mime}" style="pointer-events:none; display: block; width: 100%; height: 100%" />
17-
`
15+
shadowRoot.innerHTML = this.constructor._innerHTML
1816

1917
this._root = shadowRoot
2018

@@ -138,16 +136,10 @@ class BasePlayerElement extends HTMLElement {
138136
this._root.appendChild(style);
139137
this._root.appendChild(loadingIcon);
140138

141-
this.addEventListener('start-file', () => {
142-
loadingIcon.style.display = 'block'
143-
})
144-
145-
this.addEventListener('end-file', () => {
146-
loadingIcon.style.display = 'none'
147-
})
148-
149-
this.addEventListener('file-loaded', () => {
150-
loadingIcon.style.display = 'none'
139+
this.addEventListener('prop-change', (name, value) => {
140+
if (name === 'loading') {
141+
loadingIcon.style.display = value ? 'block' : 'none'
142+
}
151143
})
152144
}
153145
}
@@ -212,6 +204,12 @@ BasePlayerElement.prototype.addEventListener = function (type, listener, ...args
212204
}
213205

214206
class PlayerElement extends BasePlayerElement {
207+
static get _innerHTML () {
208+
return `
209+
<embed id="player" type="${mimePlayer}" style="pointer-events:none; display: block; width: 100%; height: 100%" />
210+
`
211+
}
212+
215213
static _PluginClass = PlayerPlugin
216214

217215
// Specify observed attributes so that
@@ -240,6 +238,11 @@ class PlayerElement extends BasePlayerElement {
240238
this.$player.option('osd-font-size', 30)
241239
this.$player.option('osd-duration', 2000)
242240
this.$player.option('screenshot-template', `pic-%tY%tm%td-%tH%tM-%ws`)
241+
242+
const logPath = this.getAttribute('debug-log')
243+
if (logPath) {
244+
this.$player.option('log-file', logPath)
245+
}
243246
}
244247

245248
_attributeChangedCallback (name, oldValue, newValue) {
@@ -363,6 +366,10 @@ class PlayerElement extends BasePlayerElement {
363366
if (args[0] === false) {
364367
} else {
365368
const {each, subtitles} = (args[0] || {})
369+
if (each) {
370+
const screenshotting = this.$player.props.screenshotting
371+
this.$player.triggerProp('screenshotting', !screenshotting)
372+
}
366373
this.$player.command('osd-auto', 'screenshot', (each ? 'each-frame+' : '') + (subtitles ? 'subtitles' : 'video'))
367374
}
368375
}
@@ -390,8 +397,9 @@ customElements.define('x-mpv', PlayerElement)
390397

391398
/*
392399
------------ local player -----------------
393-
<x-mpv
400+
<x-player
394401
src="string"
402+
debug-log="string"
395403
hwaccel="string"
396404
locale="string"
397405
ai-switch="string array[a,b,c,...]"
@@ -405,7 +413,7 @@ customElements.define('x-mpv', PlayerElement)
405413
mute="boolean"
406414
show-loading="boolean" # persistant
407415
>
408-
</x-mpv>
416+
</x-player>
409417
410418
[api]
411419
object.queryProperty(name) -> value or undefined
@@ -429,49 +437,4 @@ start-file: empty
429437
file-loaded: empty
430438
end-file: empty
431439
auth-require: (url)
432-
433-
------------ live player -----------------
434-
[api]
435-
object.queryProperty(name) -> value or undefined
436-
object.load(src, mode, options)
437-
object.reload()
438-
object.play()
439-
object.stop()
440-
object.screenshot({name, basePath, format, detection, maxCount, interval, scheduleType} | false)
441-
object.talk({encoding, sampleRate, bitRate} | false)
442-
object.record({name, basePath, limitBytes} | false)
443-
object.crop([x0, y0, x1, y1])
444-
445-
[property set]
446-
object.fullscreen = boolean
447-
448-
[events] object.addEventListener(event, listener)
449-
prop-change: (name, value)
450-
*name list
451-
- path
452-
- fileFormat
453-
- videoCodec
454-
- audioCodec
455-
- duration
456-
- timePos
457-
- fps
458-
- drops
459-
- fullscreen
460-
- screenshotting
461-
- talking
462-
- recording
463-
- idle
464-
- width
465-
- height
466-
- mute
467-
468-
start-file: empty
469-
file-loaded: empty
470-
end-file: empty
471-
record-path: (path)
472-
error-msg: (msg)
473-
detection: ([detection objects])
474-
screenshot: ({path, success})
475-
auth-require: (url)
476-
477440
*/

src/nacl-mpv-plugin/player.js

+25-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class MPVPlayer extends PluginBase {
1616
this.hooks = []; // array of callbacks, id is index+1
1717

1818
this.props = {
19+
loading: false,
20+
screenshotting: false,
1921
fullscreen: false,
2022
mute: false,
2123
volume: 100,
@@ -93,7 +95,8 @@ class MPVPlayer extends PluginBase {
9395
'estimated-frame-count',
9496
'hwdec-current',
9597
'options/demuxer-lavf-hacks',
96-
'options/demuxer-lavf-o' // {auth: user:pass}
98+
'options/demuxer-lavf-o', // {auth: user:pass}
99+
'track-list'
97100
].forEach(name => {
98101
this.observe_property(name)
99102
});
@@ -106,8 +109,7 @@ class MPVPlayer extends PluginBase {
106109
if (cb) {
107110
cb(e.name, e.data);
108111
} else if (e.id === undefined) {
109-
this.onPropertyChangeDefault(e.name, e.data)
110-
this._on_prop(e.name, e.data)
112+
this.triggerProp(e.name, e.data)
111113
}
112114
});
113115

@@ -190,6 +192,26 @@ class MPVPlayer extends PluginBase {
190192

191193
cont()
192194
})
195+
196+
// generate loading & screenshotting properties
197+
this.register_event('start-file', () => {
198+
this.triggerProp('loading', true)
199+
this.triggerProp('screenshotting', false)
200+
})
201+
202+
this.register_event('end-file', () => {
203+
this.triggerProp('loading', false)
204+
this.triggerProp('screenshotting', false)
205+
})
206+
207+
this.register_event('file-loaded', () => {
208+
this.triggerProp('loading', false)
209+
})
210+
}
211+
212+
triggerProp (name, value) {
213+
this.onPropertyChangeDefault(name, value)
214+
this._on_prop(name, value)
193215
}
194216

195217
handleKeyDown (e) {

0 commit comments

Comments
 (0)