本文整理汇总了C++中BMediaRoster::PrerollNode方法的典型用法代码示例。如果您正苦于以下问题:C++ BMediaRoster::PrerollNode方法的具体用法?C++ BMediaRoster::PrerollNode怎么用?C++ BMediaRoster::PrerollNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMediaRoster
的用法示例。
在下文中一共展示了BMediaRoster::PrerollNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRefFor
void
NodeHarnessWin::MessageReceived(BMessage *msg)
{
status_t err;
switch (msg->what)
{
case BUTTON_CONNECT:
mIsConnected = true;
// set the button states appropriately
mConnectButton->SetEnabled(false);
mStartButton->SetEnabled(true);
// set up the node network
{
BMediaRoster* r = BMediaRoster::Roster();
// find a node that can handle an audio file
#if TEST_WITH_AUDIO
entry_ref inRef;
dormant_node_info info;
::get_ref_for_path("/boot/optional/sound/virtual (void)", &inRef);
err = r->SniffRef(inRef, B_BUFFER_PRODUCER | B_FILE_INTERFACE, &info);
ErrorCheck(err, "couldn't find file reader node\n");
err = r->InstantiateDormantNode(info, &mConnection.producer, B_FLAVOR_IS_LOCAL);
ErrorCheck(err, "couldn't instantiate file reader node\n");
bigtime_t dummy_length; // output = media length; we don't use it
err = r->SetRefFor(mConnection.producer, inRef, false, &dummy_length);
ErrorCheck(err, "unable to SetRefFor() to read that sound file!\n");
#else
r->GetVideoInput(&mConnection.producer);
#endif
entry_ref logRef;
::get_ref_for_path("/tmp/node_log", &logRef);
mLogNode = new LoggingConsumer(logRef);
err = r->RegisterNode(mLogNode);
ErrorCheck(err, "unable to register LoggingConsumer node!\n");
// make sure the Media Roster knows that we're using the node
r->GetNodeFor(mLogNode->Node().node, &mConnection.consumer);
// trim down the log's verbosity a touch
mLogNode->SetEnabled(LOG_HANDLE_EVENT, false);
// fire off a window with the LoggingConsumer's controls in it
BParameterWeb* web;
r->GetParameterWebFor(mConnection.consumer, &web);
BView* view = BMediaTheme::ViewFor(web);
BWindow* win = new BWindow(BRect(250, 200, 300, 300), "Controls",
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS);
win->AddChild(view);
win->ResizeTo(view->Bounds().Width(), view->Bounds().Height());
win->Show();
// set the nodes' time sources
r->GetTimeSource(&mTimeSource);
r->SetTimeSourceFor(mConnection.consumer.node, mTimeSource.node);
r->SetTimeSourceFor(mConnection.producer.node, mTimeSource.node);
// got the nodes; now we find the endpoints of the connection
media_input logInput;
media_output soundOutput;
int32 count;
err = r->GetFreeOutputsFor(mConnection.producer, &soundOutput, 1, &count);
ErrorCheck(err, "unable to get a free output from the producer node");
err = r->GetFreeInputsFor(mConnection.consumer, &logInput, 1, &count);
ErrorCheck(err, "unable to get a free input to the LoggingConsumer");
// fill in the rest of the Connection object
mConnection.source = soundOutput.source;
mConnection.destination = logInput.destination;
// got the endpoints; now we connect it!
media_format format;
#if TEST_WITH_AUDIO
format.type = B_MEDIA_RAW_AUDIO; // !!! hmmm.. how to fully wildcard this?
format.u.raw_audio = media_raw_audio_format::wildcard;
#else
format.type = B_MEDIA_RAW_VIDEO; // !!! hmmm.. how to fully wildcard this?
format.u.raw_video = media_raw_video_format::wildcard;
#endif
err = r->Connect(mConnection.source, mConnection.destination, &format, &soundOutput, &logInput);
ErrorCheck(err, "unable to connect nodes");
mConnection.format = format;
// for video input, we need to set the downstream latency for record -> playback
bigtime_t latency;
r->GetLatencyFor(mConnection.producer, &latency);
printf("Setting producer run mode latency to %" B_PRIdBIGTIME "\n", latency);
r->SetProducerRunModeDelay(mConnection.producer, latency + 6000);
// preroll first, to be a good citizen
r->PrerollNode(mConnection.consumer);
r->PrerollNode(mConnection.producer);
//.........这里部分代码省略.........