• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Vic666

  • Rank

Personal Information

  • Interests
  1. Hello to all i have got a DirectX 8 game i am fixing all works well besides one DirectShow function that streams a video into a DirectDraw surface, I get an Access Violation error in ->CreateSurface...Can someone help me?. Thanks Here is the function. create_stream(const char *file_path) { IAMMultiMediaStream *local_stream_ptr; IAMMultiMediaStream *global_stream_ptr; IMediaStream *primary_video_stream_ptr; IDirectDrawMediaStream *ddraw_stream_ptr; IDirectDrawStreamSample *video_sample_ptr; LPDIRECTDRAWSURFACE video_surface_ptr; DDPIXELFORMAT ddraw_video_pixel_format; WCHAR wPath[MAX_PATH]; DDSURFACEDESC ddraw_surface_desc; RECT rect; int video_width, video_height; // Initialise the COM library. CoInitialize(NULL); // Initialise the global variables. global_stream_ptr = NULL; primary_video_stream_ptr = NULL; ddraw_stream_ptr = NULL; video_sample_ptr = NULL; video_surface_ptr = NULL; // Create the local multi-media stream object. if (CoCreateInstance(CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, IID_IAMMultiMediaStream, (void **)&local_stream_ptr) != S_OK) return(PLAYER_UNAVAILABLE); // Initialise the local stream object. if (local_stream_ptr->Initialize(STREAMTYPE_READ, AMMSF_NOGRAPHTHREAD,NULL) != S_OK) { local_stream_ptr->Release(); return(PLAYER_UNAVAILABLE); } // Add a primary video stream to the local stream object. if (local_stream_ptr->AddMediaStream(ddraw_object_ptr, &MSPID_PrimaryVideo, 0, NULL) != S_OK) { local_stream_ptr->Release(); return(PLAYER_UNAVAILABLE); } // Add a primary audio stream to the local stream object, using the // default audio renderer for playback. if (local_stream_ptr->AddMediaStream(NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL) != S_OK) { local_stream_ptr->Release(); return(PLAYER_UNAVAILABLE); } // Open the streaming media file. MultiByteToWideChar(CP_ACP, 0, file_path, -1, wPath, MAX_PATH); if (local_stream_ptr->OpenFile(wPath, 0) != S_OK) { local_stream_ptr->Release(); diagnose("Windows Media Player was unable to open stream URL %s", file_path); return(STREAM_UNAVAILABLE); } // Convert the local stream object into a global stream object. local_stream_ptr->AddRef(); global_stream_ptr = local_stream_ptr; // Initialise the primary video stream, if it exists. if (global_stream_ptr->GetMediaStream(MSPID_PrimaryVideo, &primary_video_stream_ptr) != S_OK) { warning("Could not get the primary video stream"); return(STREAM_UNAVAILABLE); } else { warning("Get the primary video stream"); } if (primary_video_stream_ptr->QueryInterface(IID_IDirectDrawMediaStream,(void **)&ddraw_stream_ptr) != S_OK) { warning("Could not obtain the DirectDraw stream object"); } else { warning("Obtain the DirectDraw stream object"); } // Determine the unscaled size of the video frame. if (ddraw_stream_ptr->GetFormat(&ddraw_surface_desc, NULL, NULL, NULL) != S_OK) { warning("Could not determine the unscaled size of the video frame"); } else { warning("Determine the unscaled size of the video frame"); } video_width = ddraw_surface_desc.dwWidth; video_height = ddraw_surface_desc.dwHeight; // Create a DirectDraw video surface using the texture pixel format, but // without an alpha channel (otherwise CreateSample will spit the dummy). memset(&ddraw_surface_desc, 0, sizeof(DDSURFACEDESC)); ddraw_surface_desc.dwSize = sizeof(DDSURFACEDESC); ddraw_surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; ddraw_surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY; ddraw_surface_desc.dwWidth = video_width; ddraw_surface_desc.dwHeight = video_height; ddraw_surface_desc.ddpfPixelFormat = ddraw_video_pixel_format; // Here i got acccess violation if (ddraw_object_ptr->CreateSurface(&ddraw_surface_desc, &video_surface_ptr, NULL) != DD_OK) { warning("Could not create a DirectDraw video surface"); } else { warning("Create a DirectDraw video surface"); } // Set the rectangle that is to be rendered to on the video surface. rect.left = 0; rect.right = video_width; rect.top = 0; rect.bottom = video_height; // Create the video sample for the video surface. if (ddraw_stream_ptr->CreateSample(video_surface_ptr, &rect, 0, &video_sample_ptr) != S_OK) { warning("Could not create the video sample for the video surface"); } else { warning("Created the video sample for the video surface"); } // Create the event that will be used to signal that a video frame is // available. video_frame_available.create_event(); // Initialise the video textures now, since we already know the // dimensions of the video frame. init_video_textures(video_width, video_height, RGB16); warning("Surface started"); streaming_video_available = true; // Get the end of stream event handle. global_stream_ptr->GetEndOfStreamEventHandle(&end_of_stream_handle); // Return a success status. warning("Stream started"); return(STREAM_STARTED); }
  • Advertisement