示例#1
0
 static void LiveStream(object pictureBox)
 {
     PictureBox imageBox = (PictureBox)pictureBox;
     Program.XBox.SetFileCacheSize(1);
     XboxVideoStream xvs = new XboxVideoStream(Program.XBox, XboxVideoStream.VideoSize.Medium, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.Immediate);
     LiveStreamRunning = true;
     xvs.Begin();
     while (LiveStreamRunning)
     {
         Waiter.Reset();
         imageBox.BackgroundImage = xvs.NextFrame();//imageBox.BackgroundImage = Program.XBox.Screenshot();
         Waiter.Set();
         Pauser.WaitOne();
     }
     xvs.End();
     Program.ScreenshotTool.checkLiveStream.Checked = false;
 }
示例#2
0
        void mnuReboot_Click(object sender, EventArgs e)
        {
            Xbox.Reboot(BootFlag.Warm);
            if (mnuMediumResolution.Checked)
            {
                Size = new Size(328, 317);
                renderWindow.Size = new Size(320, 245);

                Video = new XboxVideoStream(Xbox, XboxVideoStream.VideoSize.Medium, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.Two);
                Video.Begin();
            }
            else if (mnuFullResolution.Checked)
            {
                Size = new Size(648, 560);
                renderWindow.Size = new Size(640, 480);

                Video = new XboxVideoStream(Xbox, XboxVideoStream.VideoSize.Full, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.NoOverride);
                Video.Begin();
            }
        }
示例#3
0
        void mnuFullResolution_Click(object sender, EventArgs e)
        {
            mnuFullResolution.Checked = true;
            mnuMediumResolution.Checked = false;
            Size = new Size(648, 560);
            renderWindow.Size = new Size(640, 480);

            Video = new XboxVideoStream(Xbox, XboxVideoStream.VideoSize.Full, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.NoOverride);
            Video.Begin();
        }
示例#4
0
        void mnuMediumResolution_Click(object sender, EventArgs e)
        {
            mnuMediumResolution.Checked = true;
            mnuFullResolution.Checked = false;
            Size = new Size(328, 317);
            renderWindow.Size = new Size(320, 245);

            Video = new XboxVideoStream(Xbox, XboxVideoStream.VideoSize.Medium, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.Two);
            Video.Begin();

        }
示例#5
0
        // MCPX - Media Control Processor for Xbox

        // hook DSOUND:00382D22 ; public: long __thiscall DirectSound::CMcpxBuffer::Play(unsigned long)
        // DSOUND:003826E4 ; protected: void __thiscall DirectSound::CMcpxBuffer::PlayFromPosition(unsigned long,unsigned long)
        // DSOUND:003825A3 ; protected: void __thiscall DirectSound::CMcpxBuffer::PlayFromCurrent(unsigned long)


        //pFormat->wFormatTag          = 0x69;		// WAVE_FORMAT_XBOX_ADPCM
        //pFormat->nSamplesPerSec      = 44100
        //pFormat->nChannels           = 1;
        //pFormat->wBitsPerSample      = 4;
        //pFormat->nBlockAlign         = 36;
        //pFormat->nAvgBytesPerSec     = 24804		// 24kbs
        //pFormat->cbSize              = 2;
        //				                64 samples per block


        //pFormat->wFormatTag          = 1;		// WAVE_FORMAT_PCM
        //pFormat->nSamplesPerSec      = 44100;
        //pFormat->nChannels           = 2;
        //pFormat->wBitsPerSample      = 16;
        //pFormat->nBlockAlign         = 4;
        //pFormat->nAvgBytesPerSec     = 176400;
        //pFormat->cbSize              = 0;



        // possibly hook dsound direct media object instead, seems to be a much lower sample rate
        // todo: hook CAc97Channel::AttachPacket(DWORD dwBufferAddress, DWORD dwBufferSize)
        //const WAVEFORMATEX CAc97Device::m_wfxFormat = 
        //{ 
        //    WAVE_FORMAT_PCM,    // wFormatTag
        //    2,                  // nChannels
        //    48000,              // nSamplesPerSec
        //    192000,             // nAvgBytesPerSec
        //    4,                  // nBlockAlign
        //    16,                 // wBitsPerSample
        //    0                   // cbSize
        //};

        // 768 kilobits (93 kilobytes) per second (averaging 187.5 kilobytes a second)

        //const DWORD CAc97Channel::m_dwSilenceSize = 0x2000;
        //ASSERT((dwBufferSize / (m_pDevice->m_wfxFormat.wBitsPerSample / 8)) <= 0xFFFF);

        // so.....
        // ASSERT(dwBufferSize <= 64kb)
        // ASSERT(!(dwBufferSize % m_pDevice->m_wfxFormat.nBlockAlign));

        // **** max packet size of 64kb and requires 4-byte alignment ****

        // xmoreg
        //pFormat->wFormatTag          = WAVE_FORMAT_PCM;
        //pFormat->nSamplesPerSec      = 16000;
        //pFormat->nChannels           = 1;
        //pFormat->wBitsPerSample      = (WORD) 16;
        //pFormat->nBlockAlign         = 2;     //pFormat->wBitsPerSample * pFormat->nChannels / 8;
        //pFormat->nAvgBytesPerSec     = 32000  //pFormat->nSamplesPerSec * pFormat->nBlockAlign;
        //pFormat->cbSize              = 0;

        // dsound
        //wfx.wFormatTag = WAVE_FORMAT_PCM;
        //wfx.nChannels = 2;
        //wfx.nSamplesPerSec = 44100;
        //wfx.wBitsPerSample = 16;
        //wfx.nBlockAlign = 4;          //wfx.wBitsPerSample / 8 * wfx.nChannels;
        //wfx.nAvgBytesPerSec = 176400  //wfx.nSamplesPerSec * wfx.nBlockAlign;


        // have caved code write to our own audio queue where we can grab from there at our own leisure...

        // possibly downsample to a still acceptable quality

        // disable screensaver when this is running!!!

        // +DSobpool
        void mnuStart_Click(object sender, EventArgs e)
        {
            try
            {
                if (true)//!Xbox.Ping(500))
                {
                    // connect to xbox

                    //System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
                    Xbox.Connect();
                    SurfaceInformation si = Xbox.DisplayBufferInformation;
                    //Xbox.Reboot(BootFlag.Current);
                    //Xbox.EnableNotificationSession = true;
                    //Xbox.RegisterNotificationSession();
                    //sw.Stop();

                    //Xbox.ClearAllBreakpoints();
                    //Xbox.ContinueAllThreads();
                    //Xbox.Continue();

                    //Xbox.ReceiveNotifications();


                    //Xbox.SetBreakPoint(0x37F3A8);

                    //Xbox.ReceiveNotifications();



                    //int blahasdf = 0;


                    //string test = Xbox.StreamTest();

                    //System.Diagnostics.Stopwatch sw2 = System.Diagnostics.Stopwatch.StartNew();
                    //for (int i = 0; i < 100000; i++)
                    //{
                    //    if (sw2.ElapsedMilliseconds > 1000)
                    //        break;
                    //    Xbox.Ping();
                    //}

                    //Xbox.SetFileCacheSize(1);

                    //Xbox.SendCommand("screenshot");
                    //string line = Xbox.ReceiveSocketLine();
                    //Xbox.FlushSocketBuffer();



                    //Xbox.Reboot();      // have special reconnect command for a reboot, instead of waiting x amount of seconds, just poll x amount of seconds with a max poll count
                    //uint ptr = Xbox.AllocateMemory(0x10000);


                    //uint greatsuccess = Xbox.FreeAllMemory();




                    //while (true)
                    //{
                    //    System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();

                    //    Xbox.FastScreenshot();
                    //    sw.Stop();

                    //    //System.Threading.Thread.Sleep(10);
                    //}

                    //bool valid  = Xbox.IsValidAddress(0x3145000 - 0x1000);




                    //Xbox.Reboot(BootFlag.Wait);
                    //Xbox.LaunchTitle(
                    //using (System.IO.FileStream fs = new System.IO.FileStream("ambient_sound_dump4.bin", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read))
                    //{
                    //    while (false)
                    //    {

                    //        uint packetBuffer = Xbox.GetUInt32(0xD00614D4);
                    //        uint packetSize = Xbox.GetUInt32(0xD00614D8);
                    //        fs.Write(Xbox.GetMemory(packetBuffer, packetSize), 0, (int)packetSize);
                    //    }


                    //}






                    //Xbox.SetFileCacheSize(1);
                   // Xbox.ClearAllBreakpoints();
                   // Xbox.ContinueAllThreads();
                   //Xbox.Continue();


                   // Xbox.Pause();
                   // // kill irq level change requests so we can actually step through the code in a debugger....
                   // byte[] nopsled = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90 };
                   // byte[] nopsled2 = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90 };


                   // // 0x37EBEB DirectSound::CMcpxAPU::DoWork(void)
                   // Xbox.SetMemory(0x37EC05, nopsled);
                   // Xbox.SetMemory(0x37EC46, nopsled);
                   // Xbox.SetMemory(0x37EC5C, nopsled);
                   // Xbox.SetMemory(0x37EC75, nopsled);




                   // Xbox.Continue();


                    //// DirectSound::CMcpxVoiceClient::ActivateVoice(void)
                    //Xbox.SetMemory(0x38236F, nopsled);
                    //Xbox.SetMemory(0x3824C3, nopsled);

                    //// DirectSound::CMcpxBuffer::PlayFromPosition(unsigned long,unsigned long)
                    //Xbox.SetMemory(0x382702, nopsled);
                    //Xbox.SetMemory(0x38279D, nopsled);
                    //Xbox.SetMemory(0x3827D4, nopsled);
                    //Xbox.SetMemory(0x382857, nopsled);

                    //// DirectSound::CMcpxBuffer::PlayFromCurrent(unsigned long)
                    //Xbox.SetMemory(0x3825B5, nopsled);
                    //Xbox.SetMemory(0x3826C8, nopsled);

                    //// DirectSoundEnterCriticalSection(void)
                    //Xbox.SetMemory(0x37A169, nopsled2);
                    //Xbox.SetMemory(0x37A18A, nopsled2);
                    //Xbox.SetMemory(0x37A7FA, nopsled2);
                    //Xbox.SetMemory(0x37A823, nopsled2);

                    //Xbox.SetMemory(0x379E9E, (byte)0xC3);

 


                    //Xbox.SetMemory(0x382D22, (byte)0x55);
                    //uint addr = Xbox.GetDirectSoundPlayAddress();



                    //Xbox.ContinueAllThreads();
                    //Xbox.Continue();
                    //Xbox.SetMemory(0x382D22, 0xcccccccc);


                    //Xbox.Reboot(BootFlag.Cold);

                    //uint ac97RegisterBase = Xbox.GetUInt32(0xFEC00198);
                    //uint frontVolume = Xbox.GetUInt32(0xFEC00100 + 4);
                   // Xbox.SetMemory(0xFEC00100, new byte[128]); // kills sound

                    //byte[] data = Xbox.GetMemory(0xFEC00100, 1024);


                    //uint p = Xbox.GetUInt32(0xFE8020C8);
                    //byte[] data = Xbox.GetMemory(p, 1024);
                    //Xbox.Continue();
                    //Xbox.ClearAllBreakpoints();
                    //Xbox.ResumeThread(48);
                    //Xbox.ContinueAllThreads();

                    //// ac97 register ds:0FEC00000h[edx*2], cx
                    //uint ptr6 = Xbox.GetUInt32(0xFE8020D4);
                    //uint ptr1 = Xbox.GetUInt32(0xFE820010);
                    //uint ptr2 = Xbox.GetUInt32(0xFE8202F8);
                    //uint ptr3 = Xbox.GetUInt32(0xFE8202FC);
                    //uint ptr4 = Xbox.GetUInt32(0xFE820010);

                    //uint ptr5 = Xbox.GetUInt32(0xFEC00000);
                    //uint ptr7 = Xbox.GetUInt32(0xFEC0012C);
                    //uint ptr8 = Xbox.GetUInt32(0xFEC00130);
                    //uint ptr9 = Xbox.GetUInt32(0xFEC0017C); // ac97 channel mode
                    //Xbox.SetMemory(0xFEC0017C, 0);
                    //Xbox.SetMemory(0xFEC0017C, 0x02000000);
                   
                    //DSOUND:003847E9 ; protected: long __thiscall DirectSound::CMcpxCore::SetupFrontEndProcessor(void)
                    //Xbox.LockGPU();

                    //DateTime before = DateTime.Now;
                    //for (int i = 0; i < 1; i++)
                    //{
                    //    Xbox.FastScreenshot();
                    //}
                    //TimeSpan elapse = DateTime.Now - before;

                    // setup controller hook
                    //Xbox.Gamepad.InitializeControllerHook();
                    //Xbox.Gamepad.OverrideControllers(mnuKeyboardInput.Checked || mnuX360Input.Checked);
                    

                    // initialize video stream
                    if (mnuFullResolution.Checked)
                    {
                        // ~16fps regular immediate presentation
                        Video = new XboxVideoStream(Xbox, XboxVideoStream.VideoSize.Full, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.Immediate);
                        Video.Begin();
                    }
                    else
                    {   // ~56fps with regular immediate presentation, 30fps with regular presentation interval two
                        Video = new XboxVideoStream(Xbox, XboxVideoStream.VideoSize.Medium, XboxVideoStream.VideoQuality.Regular, XboxVideoStream.VideoPresentationInterval.Two);
                        Video.Begin();
                    }
                    status.Text = "Connected";

                    // ~63fps with a small video size using an immediate presentation window

                    // main program loop
                    Main();
                }
            }
            catch (Exception)
            {
                Xbox.Disconnect();
                mnuPause.Checked = false;
                mnuStep.Enabled = false;
                status.Text = "Disconnected";
            }
        }