8000 refactor: Move the cpp code to the common directory. · flutter-robert/flutter-webrtc@aa5300a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa5300a

Browse files
committed
refactor: Move the cpp code to the common directory.
1 parent 0d4490b commit aa5300a

23 files changed

+1617
-2052
lines changed
Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
#include "flutter_webrtc/flutter_web_r_t_c_plugin.h"
2-
3-
#include <flutter/standard_message_codec.h>
4-
5-
#include "flutter_webrtc.h"
6-
7-
const char *kChannelName = "FlutterWebRTC.Method";
8-
9-
namespace flutter_webrtc_plugin {
10-
11-
// A webrtc plugin for windows/linux.
12-
class FlutterWebRTCPluginImpl : public FlutterWebRTCPlugin {
13-
public:
14-
static void RegisterWithRegistrar(flutter::PluginRegistrar *registrar) {
15-
auto channel = std::make_unique<flutter::MethodChannel<EncodableValue>>(
16-
registrar->messenger(), kChannelName,
17-
&flutter::StandardMethodCodec::GetInstance());
18-
19-
auto *channel_pointer = channel.get();
20-
21-
// Uses new instead of make_unique due to private constructor.
22-
std::unique_ptr<FlutterWebRTCPluginImpl> plugin(
23-
new FlutterWebRTCPluginImpl(registrar, std::move(channel)));
24-
25-
channel_pointer->SetMethodCallHandler(
26-
[plugin_pointer = plugin.get()](const auto &call, auto result) {
27-
plugin_pointer->HandleMethodCall(call, std::move(result));
28-
});
29-
30-
registrar->AddPlugin(std::move(plugin));
31-
}
32-
33-
virtual ~FlutterWebRTCPluginImpl() {}
34-
35-
flutter::BinaryMessenger *messenger() { return messenger_; }
36-
37-
flutter::TextureRegistrar *textures() { return textures_; }
38-
39-
private:
40-
// Creates a plugin that communicates on the given channel.
41-
FlutterWebRTCPluginImpl(
42-
flutter::PluginRegistrar *registrar,
43-
std::unique_ptr<flutter::MethodChannel<EncodableValue>> channel)
44-
: channel_(std::move(channel)),
45-
messenger_(registrar->messenger()),
46-
textures_(registrar->texture_registrar()) {
47-
webrtc_ = std::make_unique<FlutterWebRTC>(this);
48-
}
49-
50-
// Called when a method is called on |channel_|;
51-
void HandleMethodCall(
52-
const flutter::MethodCall<EncodableValue> &method_call,
53-
std::unique_ptr<flutter::MethodResult<EncodableValue>> result) {
54-
// handle method call and forward to webrtc native sdk.
55-
webrtc_->HandleMethodCall(method_call, std::move(result));
56-
}
57-
58-
private:
59-
std::unique_ptr<flutter::MethodChannel<EncodableValue>> channel_;
60-
std::unique_ptr<FlutterWebRTC> webrtc_;
61-
flutter::BinaryMessenger *messenger_;
62-
flutter::TextureRegistrar *textures_;
63-
};
64-
65-
} // namespace flutter_webrtc_plugin
66-
67-
void FlutterWebRTCPluginRegisterWithRegistrar(
68-
FlutterDesktopPluginRegistrarRef registrar) {
69-
static auto *plugin_registrar = new flutter::PluginRegistrar(registrar);
70-
flutter_webrtc_plugin::FlutterWebRTCPluginImpl::RegisterWithRegistrar(
71-
plugin_registrar);
72-
}
1+
#include "flutter_webrtc/flutter_web_r_t_c_plugin.h"
2+
3+
#include <flutter/standard_message_codec.h>
4+
5+
#include "flutter_webrtc.h"
6+
7+
const char *kChannelName = "FlutterWebRTC.Method";
8+
9+
namespace flutter_webrtc_plugin {
10+
11+
// A webrtc plugin for windows/linux.
12+
class FlutterWebRTCPluginImpl : public FlutterWebRTCPlugin {
13+
public:
14+
static void RegisterWithRegistrar(flutter::PluginRegistrar *registrar) {
15+
auto channel = std::make_unique<flutter::MethodChannel<EncodableValue>>(
16+
registrar->messenger(), kChannelName,
17+
&flutter::StandardMethodCodec::GetInstance());
18+
19+
auto *channel_pointer = channel.get();
20+
21+
// Uses new instead of make_unique due to private constructor.
22+
std::unique_ptr<FlutterWebRTCPluginImpl> plugin(
23+
new FlutterWebRTCPluginImpl(registrar, std::move(channel)));
24+
25+
channel_pointer->SetMethodCallHandler(
26+
[plugin_pointer = plugin.get()](const auto &call, auto result) {
27+
plugin_pointer->HandleMethodCall(call, std::move(result));
28+
});
29+
30+
registrar->AddPlugin(std::move(plugin));
31+
}
32+
33+
virtual ~FlutterWebRTCPluginImpl() {}
34+
35+
flutter::BinaryMessenger *messenger() { return messenger_; }
36+
37+
flutter::TextureRegistrar *textures() { return textures_; }
38+
39+
private:
40+
// Creates a plugin that communicates on the given channel.
41+
FlutterWebRTCPluginImpl(
42+
flutter::PluginRegistrar *registrar,
43+
std::unique_ptr<flutter::MethodChannel<EncodableValue>> channel)
44+
: channel_(std::move(channel)),
45+
messenger_(registrar->messenger()),
46+
textures_(registrar->texture_registrar()) {
47+
webrtc_ = std::make_unique<FlutterWebRTC>(this);
48+
}
49+
50+
// Called when a method is called on |channel_|;
51+
void HandleMethodCall(
52+
const flutter::MethodCall<EncodableValue> &method_call,
53+
std::unique_ptr<flutter::MethodResult<EncodableValue>> result) {
54+
// handle method call and forward to webrtc native sdk.
55+
webrtc_->HandleMethodCall(method_call, std::move(result));
56+
}
57+
58+
private:
59+
std::unique_ptr<flutter::MethodChannel<EncodableValue>> channel_;
60+
std::unique_ptr<FlutterWebRTC> webrtc_;
61+
flutter::BinaryMessenger *messenger_;
62+
flutter::TextureRegistrar *textures_;
63+
};
64+
65+
} // namespace flutter_webrtc_plugin
66+
67+
void FlutterWebRTCPluginRegisterWithRegistrar(
68+
FlutterDesktopPluginRegistrarRef registrar) {
69+
static auto *plugin_registrar = new flutter::PluginRegistrar(registrar);
70+
flutter_webrtc_plugin::FlutterWebRTCPluginImpl::RegisterWithRegistrar(
71+
plugin_registrar);
72+
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
#ifndef PLUGINS_FLUTTER_WEBRTC_PLUGIN_WINDOWS_H_
2-
#define PLUGINS_FLUTTER_WEBRTC_PLUGIN_WINDOWS_H_
3-
4-
#include <flutter_plugin_registrar.h>
5-
6-
#if defined(_WINDOWS)
7-
#ifdef FLUTTER_PLUGIN_IMPL
8-
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
9-
#else
10-
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
11-
#endif
12-
#else
13-
#ifdef FLUTTER_PLUGIN_IMPL
14-
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
15-
#else
16-
#define FLUTTER_PLUGIN_EXPORT
17-
#endif
18-
#endif
19-
20-
#if defined(__cplusplus)
21-
extern "C" {
22-
#endif
23-
24-
FLUTTER_PLUGIN_EXPORT void FlutterWebRTCPluginRegisterWithRegistrar(
25-
FlutterDesktopPluginRegistrarRef registrar);
26-
27-
#if defined(__cplusplus)
28-
} // extern "C"
29-
#endif
30-
31-
#endif // PLUGINS_FLUTTER_WEBRTC_PLUGIN_WINDOWS_H_
1+
#ifndef PLUGINS_FLUTTER_WEBRTC_PLUGIN_WINDOWS_H_
2+
#define PLUGINS_FLUTTER_WEBRTC_PLUGIN_WINDOWS_H_
3+
4+
#include <flutter_plugin_registrar.h>
5+
6+
#if defined(_WINDOWS)
7+
#ifdef FLUTTER_PLUGIN_IMPL
8+
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
9+
#else
10+
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
11+
#endif
12+
#else
13+
#ifdef FLUTTER_PLUGIN_IMPL
14+
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
15+
#else
16+
#define FLUTTER_PLUGIN_EXPORT
17+
#endif
18+
#endif
19+
20+
#if defined(__cplusplus)
21+
extern "C" {
22+
#endif
23+
24+
FLUTTER_PLUGIN_EXPORT void FlutterWebRTCPluginRegisterWithRegistrar(
25+
FlutterDesktopPluginRegistrarRef registrar);
26+
27+
#if defined(__cplusplus)
28+
} // extern "C"
29+
#endif
30+
31+
#endif // PLUGINS_FLUTTER_WEBRTC_PLUGIN_WINDOWS_H_

0 commit comments

Comments
 (0)
0