📄 xaosproducer.cpp
字号:
} }}void XaoSProducer::Stop( bigtime_t performance_time, bool immediate){ bool notified = false; fprintf(stderr,"XaoSProducer::Stop (not implemented)\n"); if (!m_starting || performance_time > m_tpStart) { if (m_running || m_starting) { // It's okay to handle this Stop request.#if 0 if (m_notifyHook) { (*m_notifyHook)(m_cookie, B_WILL_STOP, performance_time, immediate); } else { Notify(B_WILL_STOP, performance_time, immediate); }#endif notified = true; m_tpStop = performance_time; m_stopping = true; TRANSPORT(stderr, "XaoSProducer stop at %.4f (now %.4f)\n", us_to_s(m_tpStop), us_to_s(TimeSource()->Now())); } }#if 0 if (immediate) { if (! notified) { if (m_notifyHook) { (*m_notifyHook)(m_cookie, B_WILL_STOP, performance_time, immediate); } else { Notify(B_WILL_STOP, performance_time, immediate); } } m_running = false; }#endif}void XaoSProducer::Seek( bigtime_t media_time, bigtime_t performance_time){ fprintf(stderr,"XaoSProducer::Seek (not implemented)\n");#if 0 // Seek sets the "media time" of a node. What the // media time is interpreted to be varies from node // to node. For a Producer that plays a sound, media // time is generally interpreted to be the time // offset of the media being played (where 0 is // the beginning of the media). if (m_notifyHook) { (*m_notifyHook)(m_cookie, B_WILL_SEEK, performance_time, media_time); } else { Notify(B_WILL_SEEK, performance_time, media_time); } m_tmSeekTo = media_time; TRANSPORT(stderr, "SEEK: Setting m_tmSeekTo to %.4f @ %.4f\n", us_to_s(m_tmSeekTo), us_to_s(performance_time)); m_tpSeekAt = performance_time; m_seeking = true; TIMING(stderr, "XaoSProducer seek at %.4f (now %.4f)\n", us_to_s(m_tpSeekAt), us_to_s(TimeSource()->Now()));#endif}void XaoSProducer::SetRunMode( run_mode mode){ fprintf(stderr,"XaoSProducer::SetRunMode (not implemented)\n");#if 0 if (mode == BMediaNode::B_OFFLINE) { int32 new_prio = suggest_thread_priority(B_OFFLINE_PROCESSING); set_thread_priority(m_thread, new_prio); } else { bigtime_t period = 10000; if (buffer_duration(m_output.format.u.raw_audio) > 0) { period = buffer_duration(m_output.format.u.raw_audio); } int32 new_prio = suggest_thread_priority(B_AUDIO_PLAYBACK, period, 1000, ProcessingLatency()); set_thread_priority(m_thread, new_prio); }#endif}void XaoSProducer::TimeWarp( bigtime_t at_real_time, bigtime_t to_performance_time){ fprintf(stderr,"XaoSProducer::TimeWarp (not implemented)\n");#if 0 // Not implemented for now -- future versions will handle this // correctly. if (m_notifyHook) { (*m_notifyHook)(m_cookie, B_WILL_TIMEWARP, at_real_time, to_performance_time); } else { Notify(B_WILL_TIMEWARP, at_real_time, to_performance_time); }#endif}void XaoSProducer::Preroll(){ fprintf(stderr,"XaoSProducer::Preroll (not implemented)\n");}void XaoSProducer::SetTimeSource( BTimeSource * ts){ fprintf(stderr,"XaoSProducer::SetTimeSource (not implemented)\n"); BBufferProducer::SetTimeSource(ts);}status_t XaoSProducer::HandleMessage( int32 message, const void * data, size_t size){ // Check with each of our superclasses to see if they // understand the message. If none of them do, call // BMediaNode::HandleBadMessage(). if (BMediaNode::HandleMessage(message, data, size) && BFileInterface::HandleMessage(message, data, size) && BBufferProducer::HandleMessage(message, data, size)) { BMediaNode::HandleBadMessage(message, data, size); return B_ERROR; } return B_OK;}//////////////////////////////////////////////////////////////////////////////////// BMediaNode-derived methods//////////////////////////////////////////////////////////////////////////////////status_t XaoSProducer::FormatSuggestionRequested( media_type type, int32 /* quality */, media_format * format){ NODE(stderr, "XaoSProducer::FormatSuggestionRequested()\n"); if (type <= 0) type = B_MEDIA_RAW_VIDEO; if (type != B_MEDIA_RAW_VIDEO) return B_MEDIA_BAD_FORMAT; format->type = type; format->u.raw_video = media_raw_video_format::wildcard; // format->u.raw_video.field_rate = PREFFERED_FIELD_RATE; // Interlace is not supported by XaoS format->u.raw_video.interlace = 1; format->u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT; //format->u.raw_video.display.format = B_RGB32;#if !NDEBUG char fmt[100]; string_for_format(*format, fmt, 100); FORMAT(stderr, "return format %s\n", fmt);#endif return B_OK;}status_t XaoSProducer::FormatProposal( const media_source & output, media_format * format){ fprintf(stderr,"XaoSProducer::FormatProposal!\n"); if (output != m_output.source) { NODE(stderr, "XaoSProducer::FormatProposal(): bad source\n"); return B_MEDIA_BAD_SOURCE; } if (format->type <= 0) { FormatSuggestionRequested(B_MEDIA_RAW_VIDEO, 0, format); } else { if (format->type != B_MEDIA_RAW_VIDEO) { goto err; } /* We require non interlaced TOP_LEFT_RIGHT oriented mode */ fprintf(stderr,"XaoSProducer::interlace %i!\n", format->u.raw_video.interlace); if (format->u.raw_video.interlace <= media_raw_video_format::wildcard.interlace) { format->u.raw_video.interlace = 1; } else if (format->u.raw_video.interlace!=1) goto err; fprintf(stderr,"XaoSProducer::orientation %i!\n", format->u.raw_video.orientation); if (format->u.raw_video.orientation <= media_raw_video_format::wildcard.orientation) { format->u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT; } else if (format->u.raw_video.orientation != B_VIDEO_TOP_LEFT_RIGHT) goto err;#if 0 fprintf(stderr,"XaoSProducer::field rate %f!\n", format->u.raw_video.field_rate); if (format->u.raw_video.field_rate <= media_raw_video_format::wildcard.field_rate) { format->u.raw_video.field_rate = PREFFERED_FIELD_RATE; } fprintf(stderr,"XaoSProducer::first_active %i!\n", format->u.raw_video.first_active); if (format->u.raw_video.first_active <= media_raw_video_format::wildcard.first_active) { format->u.raw_video.first_active = 0; } fprintf(stderr,"XaoSProducer::last_active %i!\n", format->u.raw_video.last_active); if (format->u.raw_video.last_active <= media_raw_video_format::wildcard.last_active) { format->u.raw_video.last_active = PREFFERED_HEIGHT-1; } fprintf(stderr,"XaoSProducer::width_aspect %i!\n", format->u.raw_video.pixel_width_aspect); if (format->u.raw_video.pixel_width_aspect <= media_raw_video_format::wildcard.pixel_width_aspect) { format->u.raw_video.pixel_width_aspect = 1; } fprintf(stderr,"XaoSProducer::height_aspect %i!\n", format->u.raw_video.pixel_height_aspect); if (format->u.raw_video.pixel_height_aspect <= media_raw_video_format::wildcard.pixel_height_aspect) { format->u.raw_video.pixel_height_aspect = 1; } fprintf(stderr,"XaoSProducer::display.format %i!\n", format->u.raw_video.display.format); if (format->u.raw_video.display.format <= media_raw_video_format::wildcard.display.format) { format->u.raw_video.display.format = PREFFERED_COLOR_SPACE; } fprintf(stderr,"XaoSProducer::display.line_width %i!\n", format->u.raw_video.display.line_width); if (format->u.raw_video.display.line_width <= media_raw_video_format::wildcard.display.line_width) { format->u.raw_video.display.line_width = PREFFERED_WIDTH; } fprintf(stderr,"XaoSProducer::display.line_count %i!\n", format->u.raw_video.display.line_count); if (format->u.raw_video.display.line_count <= media_raw_video_format::wildcard.display.line_width) { format->u.raw_video.display.line_count = PREFFERED_HEIGHT; } fprintf(stderr,"XaoSProducer::display.bytes_per_row %i!\n", format->u.raw_video.display.bytes_per_row); if (format->u.raw_video.display.bytes_per_row <= media_raw_video_format::wildcard.display.bytes_per_row) { int mult; switch (format->u.raw_video.display.format) { /*The 24-bit versions are not compiled in, because BeOS don't support them in most cases. Use 32 instead. */ case B_RGB24: case B_RGB24_BIG: mult=3*8; break; case B_RGB32: case B_RGB32_BIG: case B_RGBA32: case B_RGBA32_BIG: mult=4*8; break; case B_RGB16: case B_RGB16_BIG: case B_RGBA15: case B_RGBA15_BIG: case B_RGB15: case B_RGB15_BIG: mult=2*8; break; case B_CMAP8: case B_GRAY8: mult=8; case B_GRAY1: mult=1; break; default: abort(); } format->u.raw_video.display.bytes_per_row = (mult*m_raw_format.display.line_width+7)/8; } fprintf(stderr,"XaoSProducer::display.bytes_per_row %i!\n", format->u.raw_video.display.bytes_per_row);#endif } //format->u.raw_audio.byte_order = media_raw_audio_format::wildcard.byte_order;#if !NDEBUG char fmt[100]; string_for_format(*format, fmt, 100); FORMAT(stderr, "FormatProposal: %s\n", fmt);#endif // everything checks out and we've filled in the // wildcards that we care about. return B_OK;err: // we didn't like whatever they suggested. Counter- // propose with something acceptable and return an // error. fprintf(stderr, "Incompatible format!\n"); FormatSuggestionRequested(B_MEDIA_RAW_VIDEO, 0, format); return B_MEDIA_BAD_FORMAT;}status_t XaoSProducer::FormatChangeRequested( const media_source & source, const media_destination & /* destination */, media_format * io_format, int32 * out_change_count){ fprintf(stderr,"XaoSProducer::FormatChangeRequested (not implemented)\n"); status_t err = FormatProposal(source, io_format); if (err < B_OK) return err;#if 0 m_output.format = *io_format; if (m_notifyHook) { (*m_notifyHook)(m_cookie, B_FORMAT_CHANGED, &m_output.format.u.raw_audio); } else { Notify(B_FORMAT_CHANGED, &m_output.format.u.raw_audio); }#endif *out_change_count = IncrementChangeTag(); alloc_buffers(); return B_OK;}status_t XaoSProducer::GetNextOutput( int32 * cookie, media_output * out_output){ NODE(stderr, "XaoSProducer: GetNextOutput( %i)\n", *cookie); if (*cookie == 0) { *out_output = m_output; *cookie = 1; } else { printf("Bad luck\n"); // There's only one output. return B_BAD_INDEX; } return B_OK;}status_t XaoSProducer::DisposeOutputCookie( int32 /* cookie */){ return B_OK;}status_t XaoSProducer::SetBufferGroup( const media_source & for_source, BBufferGroup * group){ NODE(stderr, "XaoSProducer: SetBufferGroup\n"); if (for_source != m_output.source) { // We only accept buffer groups aimed at our single output. NODE(stderr, "XaoSProducer::SetBufferGroup(): bad source\n"); return B_MEDIA_BAD_SOURCE; } // We always own our buffer group. If we're being told to use a // different buffer group, we delete our current buffer group // first. // // Note: Deleting a buffer group attempts to reclaim all of its // outstanding buffers. So, if we're holding on to any buffers, // we must recycle them before deleting the group, unless we // crave a big hunk o' deadlock pie. if (group != m_buffers) { delete m_buffers; m_buffers = group; } return B_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -