.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-static int decode_interrupt_cb(void) | |
+static int decode_interrupt_cb(void *ctx) | |
{ | |
- q_pressed += read_key() == 'q'; | |
- return q_pressed > 1; | |
+ return received_nb_signals > 1; | |
} | |
-static int ffmpeg_exit(int ret) | |
+static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; |
舊式的 io interrupt callback 是一個 global function pointer:
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set global callback (old style) | |
// callback type=> int (*interrupt_cb)(void) | |
avio_set_interrupt_cb(decode_interrupt_cb); |
新式的 io interrupt callback 使用一個 struct 包起來,設定在各別的 AVFormatContext:
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set callback to AVFormatContext*->interrupt_callback | |
// callback type=> int (*interrupt_cb)(void*) | |
// interrupt_callback type=> AVIOInterruptCB | |
// ex: static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; | |
oc->interrupt_callback = int_cb; |
要修改的部分雖然不太多,但 callback function 的參數有改,這是得注意的部分 :D
沒有留言:
張貼留言