473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Windows Media SDK and stringbuilder marshalling

Hi,

Im have implemented the IWMCredentialCallback for a windows media pushsink in my application.

My pushsink works fine for publishing to the windows media server when no authentication is required, but when credentials are required, my implentation of AcquireCredentials is called, but i cannot seem to copy my user details into the stringbuilder buffers successfully.


I am using this ComImport...


Expand|Select|Wrap|Line Numbers
  1. ..
  2.  
  3.     [ComImport]
  4.     [Guid("342e0eb7-e651-450c-975b-2ace2c90c48e")]
  5.         [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  6.     public interface IWMCredentialCallback
  7.     {
  8.         void AcquireCredentials(
  9.           [In, MarshalAs(UnmanagedType.LPWStr)] string bstrRealm,
  10.           [In, MarshalAs(UnmanagedType.LPWStr)] string bstrSite,
  11.           [In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszUser,
  12.           [In] uint cchUser,
  13.           [In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszPassword,
  14.           [In] uint cchPassword,
  15.           [In] IntPtr hrStatus,
  16.           [In, Out] ref uint pdwFlags);
  17.     }
  18.  
  19. ..


And this is my method implementation...


Expand|Select|Wrap|Line Numbers
  1. ..
  2.  
  3.         public void AcquireCredentials(string bstrRealm, string bstrSite, StringBuilder pwszUser, uint cchUser, StringBuilder pwszPassword, uint cchPassword, IntPtr hrStatus, ref uint pdwFlags)
  4.         {
  5.  
  6.         // the bstrRealm here is correct as the name of the server i am publishing to
  7.  
  8.  
  9.         pwszUser.Append("username");        // these lines throw "System.ArgumentOutOfRangeException"
  10.         pwszPassword.Append("password");    // capacity was less than the current size
  11.  
  12.  
  13.  
  14.  
  15.         pdwFlags = 0x00;
  16.  
  17.         }
  18.  
  19. ..

i have tried various things to copy the username into the stringbuilder
the pwszUser has a maxcapacity of zero, and so i cannot write anything into it
i cannot reset the capacity of it either, as it throws "capacity exceeds maxcapacity"

pwszPassword also shows zero capacity, however when the method is called a second and third time trying to authenticate,
its buffer shows a capacity of 8 and prints '*' chars to the debug output

my understanding of using stringbuilder for marshal is to make sure the capacity is set first.
This method is initially called by the media server when the pushsink connects, so i have no control over this.

From Microsoft description of the SDK AcquireCredentials, the value of cchUser is supposed to be the buffer size allocated to pwszUser.
This is clearly not happening.

Perhaps i have implemented this interface the wrong way?


Can anyone help me with this?
Jul 9 '08 #1
0 1136

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philip Korolev | last post by:
Hi All. I am looking for articles on Windows Media development in ASP.NET pages. Dynamically adding playlists etc. Can I use server side code or is it all client side controlled? Spent the last...
1
by: Lonewolf | last post by:
Hi everyone, pls forgive me for my lack of knowledge and skills if my question sounds very stupid. I am trying to implement a video conferencing software and I am currently looking at a few set of...
1
by: Stephen Adam | last post by:
Hi there, Have spent a while trying to find out how to connect to Windows Media Player through COM. Unfortunately there doesnt seem to be much stuff about it on the web. What I need to do is...
3
by: UJ | last post by:
I have a .avi file that uses the Divx codec. If I load it with windows media player program it works fine. If I load it using my control in a program, it doesn't display. Over standard media files...
1
by: sri2097 | last post by:
Basically, I want to check if a URL is playable or not (without actually playing it). i.e. given a URL I want to write an automation script to figure it out for me if it's playable or not. If...
3
by: Morgan Cheng | last post by:
In P/Invoke situation, If some *out* parameter is LPWSTR, I can use string or StringBuilder. However, there is one problem about StringBuilder. By default, its Capacity is 16. If the returned...
4
by: hzgt9b | last post by:
Using VS 2003, VB.NET and/or ASP.NET 2.0, BACKGROUND I have a window forms based application that contains a TreeView control and a WebBroswer (AxSHDocVw.AxWebBrowser) control. The TreeView is...
3
by: sean.j.gage | last post by:
I'm attempting to download a windows media video file from a remote server and I would like to start playing it as soon as it starts downloading. Is there some special way to save the file that...
0
by: artsohc | last post by:
Hey Everyone, this is my first time posting so go easy on me. I am trying to hook up music-on-hold at the office I work at. I got all the music loaded and I got Windows Media Player working while...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.