-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoWindow.h
74 lines (58 loc) · 1.78 KB
/
VideoWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <gst/gst.h>
#include <gst/interfaces/xoverlay.h>
namespace GStreamer {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
public ref class VideoWindow : public System::Windows::Forms::Form
{
public:
VideoWindow(System::String^ pipelineString)
{
InitializeComponent();
IntPtr ptr = Marshal::StringToHGlobalAnsi(pipelineString);
gst_init(NULL, NULL);
_handle = Handle.ToInt32();
const char* ppl = (const gchar*)ptr.ToPointer();
_pipeline = gst_parse_launch(ppl, NULL);
gst_element_set_state(_pipeline, GST_STATE_READY);
GstElement* video_sink = gst_bin_get_by_interface(GST_BIN(_pipeline), GST_TYPE_X_OVERLAY);
if (!video_sink) {
GST_ERROR("Could not retrieve video sink");
return;
}
gst_x_overlay_set_window_handle(GST_X_OVERLAY(video_sink), _handle);
gst_element_set_state(_pipeline, GST_STATE_PLAYING);
Marshal::FreeHGlobal(ptr);
}
protected:
~VideoWindow()
{
gst_element_set_state(_pipeline, GST_STATE_NULL);
gst_object_unref(_pipeline);
if (components)
{
delete components;
}
}
private:
static guintptr _handle;
GstElement *_pipeline;
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->components = gcnew System::ComponentModel::Container();
this->Size = System::Drawing::Size(300,300);
this->Text = L"VideoWindow";
this->Padding = System::Windows::Forms::Padding(0);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
};
}