Created
January 29, 2016 06:41
-
-
Save nshiba/4d8f5a4310c5216829b3 to your computer and use it in GitHub Desktop.
プログラムとffmpeg間の通信サンプル
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
// プログラムとFfmpeg間の通信はnamed pipeを使用して行っています. | |
//named pipe へ書き込み準備 | |
// Create a pipe to send data | |
HANDLE pipe = CreateNamedPipe( | |
"\\\\.\\pipe\\my_pipe", // パイプ名.この名前にアクセスすればデータが受け取れる | |
PIPE_ACCESS_OUTBOUND, // 1-way pipe -- send only | |
PIPE_TYPE_BYTE, // send data as a byte stream | |
1, // only allow 1 instance of this pipe | |
0, // no outbound buffer | |
0, // no inbound buffer | |
0, // use default wait time | |
NULL // use default security attributes | |
); | |
if (pipe == NULL || pipe == INVALID_HANDLE_VALUE) { | |
std::wcout << "Failed to create outbound pipe instance."; | |
// look up error code here using GetLastError() | |
return; | |
} | |
std::wcout << "Waiting for a client to connect to the pipe..." << std::endl; | |
// This call blocks until a client process connects to the pipe | |
BOOL result = ConnectNamedPipe(pipe, NULL); | |
if (!result) { | |
std::wcout << "Failed to make connection on named pipe." << std::endl; | |
// look up error code here using GetLastError() | |
CloseHandle(pipe); // close the pipe | |
system("pause"); | |
return; | |
} | |
//書き込み準備ここまで*/ | |
// ---------------- | |
// ~~~~~ 処理 ~~~~~ | |
// ---------------- | |
DWORD numBytesWritten = 0; | |
result = WriteFile( | |
pipe, // handle to our outbound pipe | |
result_image.data, // 画像データ | |
DST_WIDTH * DST_HEIGHT * 3, // 画像サイズ | |
&numBytesWritten, // will store actual amount of data sent | |
NULL // not using overlapped IO | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment