TimeSourceObject::TimeSourceObject(const media_node& node) : BMediaNode("some timesource object", node.node, node.kind), BTimeSource(node.node) { TRACE("TimeSourceObject::TimeSourceObject enter, id = %ld\n", node.node); if (fControlPort > 0) delete_port(fControlPort); // We use the control port of the real time source object. // this way, all messages are send to the real time source, // and this shadow object won't receive any. fControlPort = node.port; ASSERT(fNodeID == node.node); ASSERT(fKinds == node.kind); if (node.node == NODE_SYSTEM_TIMESOURCE_ID) { strcpy(fName, "System clock"); fIsRealtime = true; } else { live_node_info liveNodeInfo; if (BMediaRoster::Roster()->GetLiveNodeInfo(node, &liveNodeInfo) == B_OK) strlcpy(fName, liveNodeInfo.name, B_MEDIA_NAME_LENGTH); else snprintf(fName, B_MEDIA_NAME_LENGTH, "timesource %ld", node.node); } AddNodeKind(NODE_KIND_SHADOW_TIMESOURCE); AddNodeKind(NODE_KIND_NO_REFCOUNTING); TRACE("TimeSourceObject::TimeSourceObject leave, node id %ld\n", fNodeID); }
VideoConsumer::VideoConsumer(const char* name, BMediaAddOn* addon, const uint32 internal_id, NodeManager* manager, VideoTarget* target) : BMediaNode(name), BMediaEventLooper(), BBufferConsumer(B_MEDIA_RAW_VIDEO), fInternalID(internal_id), fAddOn(addon), fConnectionActive(false), fMyLatency(3000), fOurBuffers(false), fBuffers(NULL), fManager(manager), fTargetLock(), fTarget(target), fLastBufferIndex(-1), fTryOverlay(true) { FUNCTION("VideoConsumer::VideoConsumer\n"); AddNodeKind(B_PHYSICAL_OUTPUT); SetEventLatency(0); for (uint32 i = 0; i < kBufferCount; i++) { fBitmap[i] = NULL; fBufferMap[i] = NULL; } SetPriority(B_DISPLAY_PRIORITY); }
FireWireDVNode::FireWireDVNode(BMediaAddOn* addon, const char* name, int32 internal_id, FireWireCard* card) : BMediaNode(name), BBufferProducer(B_MEDIA_ENCODED_VIDEO), BControllable(), BMediaEventLooper(), fOutputEnabledEncVideo(false), fCard(card), fCaptureThreadsActive(false), fThreadIdCardReader(-1), fTerminateThreads(false), fBufferGroupEncVideo(0), fCaptureActive(false) { CALLED(); AddNodeKind(B_PHYSICAL_INPUT); // AddNodeKind(B_PHYSICAL_OUTPUT); fInternalID = internal_id; fAddOn = addon; fInitStatus = B_OK; fDefaultFormatEncVideo.type = B_MEDIA_ENCODED_VIDEO; }
BFileInterface::BFileInterface() : BMediaNode("called by FileInterface") { CALLED(); AddNodeKind(B_FILE_INTERFACE); }
/* explicit */ BTimeSource::BTimeSource(media_node_id id) : BMediaNode("This one is never called"), fStarted(false), fArea(-1), fBuf(NULL), fSlaveNodes(NULL), fIsRealtime(false) { CALLED(); AddNodeKind(B_TIME_SOURCE); ASSERT(id > 0); // printf("###### explicit BTimeSource::BTimeSource() id %ld, name %s\n", id, Name()); // This constructor is only called by the derived BPrivate::media::TimeSourceObject objects // We create a clone of the communication area char name[32]; area_id area; sprintf(name, "__timesource_buf_%" B_PRId32, id); area = find_area(name); if (area <= 0) { ERROR("BTimeSource::BTimeSource couldn't find area, node %" B_PRId32 "\n", id); return; } sprintf(name, "__cloned_timesource_buf_%" B_PRId32, id); fArea = clone_area(name, reinterpret_cast<void **>(const_cast<BPrivate::media::TimeSourceTransmit **>(&fBuf)), B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, area); if (fArea <= 0) { ERROR("BTimeSource::BTimeSource couldn't clone area, node %" B_PRId32 "\n", id); return; } }
BBufferConsumer::BBufferConsumer(media_type consumerType) : BMediaNode("called by BBufferConsumer"), fConsumerType(consumerType), fBufferCache(new BPrivate::BufferCache), fDeleteBufferGroup(0) { CALLED(); AddNodeKind(B_BUFFER_CONSUMER); }
LegacyAudioConsumer::LegacyAudioConsumer( BMediaAddOn *addon, const char *name, int32 internal_id ) : BMediaNode( name ), BBufferConsumer( B_MEDIA_RAW_AUDIO ) { mInitStatus = B_NO_INIT; mAddOn = addon; mId = internal_id; mBuffers = NULL; mThread = -1; mProcessingLatency = 0LL; mRunning = false; mConnected = false; io_buf1 = NULL; AddNodeKind( B_PHYSICAL_OUTPUT ); sprintf( device_name, "/dev/audio/old/%s", name ); //open the device driver for output fd = open( device_name, O_WRONLY ); if ( fd == 0 ) { return; } mBuffer_size = 4096; io_buf1 = static_cast<audio_buffer_header *>( malloc( 2 * ( sizeof( audio_buffer_header ) + mBuffer_size )) ); if ( io_buf1 == NULL ) { close( fd ); return; } io_buf2 = reinterpret_cast<audio_buffer_header *>( reinterpret_cast<char *>(const_cast<audio_buffer_header *>( io_buf1 )) + sizeof( audio_buffer_header ) + mBuffer_size); io_buf1->reserved_1 = sizeof( audio_buffer_header ) + mBuffer_size; io_buf2->reserved_1 = sizeof( audio_buffer_header ) + mBuffer_size; mInitStatus = B_OK; return; }
void TVideoPreviewView::Init() { // We don't need a background color SetViewColor(B_TRANSPARENT_32_BIT); AddNodeKind(B_PHYSICAL_OUTPUT); mPort = create_port(3, "TVideoPreviewView input"); mDestination.port = mPort; mDestination.id = 0; mLast = 0; mRunMode = B_DROP_DATA; m_Bitmap = NULL; vThread = 0; mThread = 0; mControlQuit = false; mDisplayQuit = false; mConnected = false; mRunning = false; mStarting = false; mStopping = false; mSeeking = false; mStartTime = 0; /* when to start in performance time */ mStopTime = 0; /* when to stop in performance time */ mSeekTime = 0; mMediaTime = 0; mDeltaTime = 0; mMyLatency = 10000; mDownstreamLatency = 0; mBufferAvailable = 0; mServiceLock = create_sem (1, "Video Consumer Service Lock"); if (mServiceLock < B_NO_ERROR) { ERROR("TVideoPreviewView: couldn't create ServiceLock semaphore\n"); } mThread = spawn_thread(sRun, "TVideoPreviewView:run", B_REAL_TIME_PRIORITY, this); resume_thread(mThread); }
BTimeSource::BTimeSource() : BMediaNode("This one is never called"), fStarted(false), fArea(-1), fBuf(NULL), fSlaveNodes(new BPrivate::media::SlaveNodes), fIsRealtime(false) { CALLED(); AddNodeKind(B_TIME_SOURCE); // printf("##### BTimeSource::BTimeSource() name %s, id %ld\n", Name(), ID()); // This constructor is only called by real time sources that inherit // BTimeSource. We create the communication area in FinishCreate(), // since we don't have a correct ID() until this node is registered. }
FinePixProducer::FinePixProducer( BMediaAddOn *addon, const char *name, int32 internal_id) : BMediaNode(name), BMediaEventLooper(), BBufferProducer(B_MEDIA_ENCODED_VIDEO), BControllable() { //status_t err; fInitStatus = B_NO_INIT; /* Only allow one instance of the node to exist at any time */ if (atomic_add(&fInstances, 1) != 0) return; fInternalID = internal_id; fAddOn = addon; fBufferGroup = NULL; fThread = -1; fFrameSync = -1; fProcessingLatency = 0LL; fRunning = false; fConnected = false; fEnabled = false; fOutput.destination = media_destination::null; AddNodeKind(B_PHYSICAL_INPUT); fDeltaBuffer = NULL; //øyvind fCam = new FinePix(); fInitStatus = B_OK; return; }
ESDSinkNode::ESDSinkNode(BMediaAddOn *addon, char* name, BMessage * config) : BMediaNode(name), BBufferConsumer(B_MEDIA_RAW_AUDIO), #if ENABLE_INPUT BBufferProducer(B_MEDIA_RAW_AUDIO), #endif #ifdef ENABLE_TS BTimeSource(), #endif BMediaEventLooper(), fThread(-1), fDevice(NULL), fTimeSourceStarted(false), fWeb(NULL), fConfig(*config) { CALLED(); fInitCheckStatus = B_NO_INIT; fAddOn = addon; fId = 0; AddNodeKind( B_PHYSICAL_OUTPUT ); #if ENABLE_INPUT AddNodeKind( B_PHYSICAL_INPUT ); #endif // initialize our preferred format object memset(&fPreferredFormat, 0, sizeof(fPreferredFormat)); // set everything to wildcard first fPreferredFormat.type = B_MEDIA_RAW_AUDIO; #if ESD_FMT == 8 fPreferredFormat.u.raw_audio.format = media_raw_audio_format::B_AUDIO_UCHAR; #else fPreferredFormat.u.raw_audio.format = media_raw_audio_format::B_AUDIO_SHORT; #endif fPreferredFormat.u.raw_audio.valid_bits = 0; fPreferredFormat.u.raw_audio.channel_count = 2; fPreferredFormat.u.raw_audio.frame_rate = ESD_DEFAULT_RATE; fPreferredFormat.u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; // we'll use the consumer's preferred buffer size, if any fPreferredFormat.u.raw_audio.buffer_size = ESD_MAX_BUF / 4 /* * (fPreferredFormat.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK) * fPreferredFormat.u.raw_audio.channel_count*/; if(config) { //PRINT_OBJECT(*config); config->FindString("hostname", &fHostname); } if (fHostname.Length() < 1) fHostname = "172.20.109.151";//"192.168.0.2"; fPort = ESD_DEFAULT_PORT; fEnabled = false; fDevice = new ESDEndpoint(); /* if (fDevice) { if (fDevice->Connect(fHostname.String()) >= 0) { fDevice->SetCommand(); fDevice->SetFormat(ESD_FMT, 2); //fDevice->GetServerInfo(); fInitCheckStatus = fDevice->SendDefaultCommand(); } } */ if (!fDevice) return; fInitCheckStatus = B_OK; }