Skip to content

Connecting NativePlayer rendering with pp::Graphics3D issue #5

@rockinggit

Description

@rockinggit

Hello,

I am trying to set up NativePlayer Elementary Stream player rendering with openGL to improve its performance.

My basic set up of NativePlayer is working.
I changed line in es_dash_player_controller when creating player to like below.
player_ = make_shared(Samsung::NaClPlayer::MediaPlayer::BindToDisplayMode::DoNotBindPlayerToDisplay);

So that player will not draw itself.

for trial I first tried to do rendering with pp::Graphics2D which works.
but when i tried to connect with pp::Graphics3D it does not display anything.
Can someone tell me if an doing something wrong. I know i can use shaders etc with openGL calls but that is not useful it seems as Nacl::Player does not provide buffer which it is going to draw on display. So i am trying this way and Given NaclPlayer option of DoNotBindPlayerToDisplay , It seems to me it should be able to connect with pp::Graphics3D rendering.

my code is something like below: (for simplicity of reading i have given only changed/new functions. changes are in #ifdef USE_GRAPHICS3D)
/////////////////////////////////////////////////////////
#include "ppapi/cpp/graphics_3d.h"
#include <GLES2/gl2.h>
#include "ppapi/lib/gl/gles2/gl2ext_ppapi.h"

pp::Graphics3D context_; /**< Graphics3D context. */

void NativePlayer::DidChangeView(const pp::View& view) {
LOG_ERROR("DidChangeView");
const pp::Rect pp_r{view.GetRect().size()};
if (rect_ == pp_r) return;
rect_ = pp_r;
int32_t new_width = view.GetRect().width() * device_scale_;
int32_t new_height = view.GetRect().height() * device_scale_;
#ifdef USE_GRAPHICS3D
device_scale_ = view.GetDeviceScale();
pp::Size new_size = pp::Size(view.GetRect().width() * device_scale_,
view.GetRect().height() * device_scale_);
if (context_.is_null()) {
if (!CreateContext(new_size)) {
LOG_ERROR("Couldn't initialize GLES library!");
return;
}
} else {
// Resize the buffers to the new size of the module.
int32_t result = context_.ResizeBuffers(new_width, new_height);
if (result < 0) {
LOG_ERROR("Unable to resize buffers to %d x %d!", new_width,
new_height);
return;
}
}
LOG_ERROR("Initialized module's view with resolution %dx%d",
new_width, new_width);
#endif
pp::VarDictionary message;
message.Set(Communication::kKeyMessageToPlayer,
static_cast(Communication::MessageToPlayer::kChangeViewRect));
message.Set(Communication::kKeyXCoordination, pp_r.x());
message.Set(Communication::kKeyYCoordination, pp_r.y());
message.Set(Communication::kKeyWidth, pp_r.width());
message.Set(Communication::kKeyHeight, pp_r.height());
LOG_DEBUG("View changed to: (x:%d, y: %d), (w:%d, h:%d)", pp_r.x(), pp_r.y(),
pp_r.width(), pp_r.height());
DispatchMessage(message);
#ifdef USE_GRAPHICS3D
MainLoopIteration(0);
///////////////////////////////
#endif
}

#ifdef USE_GRAPHICS3D
void NativePlayer::MainLoopIteration(int32_t) {
if (context_.is_null()) {
LOG_ERROR("Graphics3D context is null");
return;
}
glClearColor(1.0, 0.0, 0.0, 1);
glClearDepthf(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
int ret = context_.SwapBuffers(cc_factory_.NewCallback(
&NativePlayer::MainLoopIteration));
if (ret != -1)
LOG_ERROR("SwapBuffers returned %d\n", ret);

}
bool NativePlayer::CreateContext(const pp::Size& new_size) {
if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
Logger::Error("Unable to initialize GLES PPAPI!");
return false;
}
LOG_ERROR("CreateContext");
const int32_t attrib_list[] = {
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
PP_GRAPHICS3DATTRIB_WIDTH, new_size.width(),
PP_GRAPHICS3DATTRIB_HEIGHT, new_size.height(),
PP_GRAPHICS3DATTRIB_NONE
};
context_ = pp::Graphics3D(this, attrib_list);
if (!BindGraphics(context_)) {
Logger::Error("Unable to bind 2D context!");
LOG_ERROR("Unable to bind 2D context!");
context_ = pp::Graphics3D();
return false;
}
glSetCurrentContextPPAPI(context_.pp_resource());
LOG_ERROR("CreateContext Success");
return true;
}
#ifdef USE_GRAPHICS3D
}

Any input are highly appreciated.Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions