cplussharp / graph-studio-next

GraphStudioNext is a tool for developers to build and test DirectShow Graphs
354 stars 94 forks source link

Relative paths to referenced media #319

Closed roman380 closed 2 years ago

roman380 commented 6 years ago

If files referenced by IFileSourceFilter and IFileSinkFilter interfaces are relative (same directory or a subdirectory) to GRFX/XML file, would we be interested in storing relative path? This would help when the entire containing directory is moved.

mikecopperwhite commented 6 years ago

Interesting idea:

Would the filename be relative to the GRF or GRFX path? What should happen in an unsaved graph?

One wrinkle:

According to: https://msdn.microsoft.com/en-us/library/windows/desktop/dd389983(v=vs.85).aspx

For the File Source (Async) filter, pszFileName specifies the absolute path name of a local file. For the File Source (URL) filter, pszFileName specifies the URL of a file to download. For other filter implementations, pszFileName might require a file name or a URL, depending on the filter.

We could try loading as an absolute file or URL first then as a relative file or URL if that fails but it would be a GSN extension feature.

roman380 commented 6 years ago

It can be relative to GRFX file, right. After all, it was the original idea that move of GRFX with its dependencies should not break the structure. This certainly assumes GSN itself makes relative from absolute and vice versa on save/load. I actually have a working draft and it seems to be working fine (for GRFX).

mikecopperwhite commented 6 years ago

Makes sense to make it a GRFX feature. There's no particular reason we couldn't store relative and absolute names under different keys and use whichever works.

roman380 commented 6 years ago

Good point about saving both. so I added saving both absolute and relative and load tries to load from absolute first (that is, the way it was before) and falls back to relative path only on failure with absolute.

This way we don't need to limit relative path to this or subdirectory, since it's anyway a recovery code path.